Skip to content

Commit a55004b

Browse files
committed
PowerShell Core
1 parent 54fef15 commit a55004b

File tree

6 files changed

+49
-65
lines changed

6 files changed

+49
-65
lines changed

Microsoft.PowerShell_profile.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (Get-Module -ListAvailable -Name 'Pscx') {
1212
Import-Module Pscx -arg (Join-Path $profileDir Pscx.UserPreferences.ps1)
1313
}
1414

15-
if (Get-Module -ListAvailable -Name 'PSReadline') {
15+
if (Get-Module -ListAvailable -Name 'PSReadLine') {
1616
. (Join-Path $profileDir PSReadlineProfile.ps1)
1717
}
1818

@@ -26,9 +26,8 @@ if (Test-Path "${Env:USERPROFILE}\.jabba\jabba.ps1") {
2626
. (Join-Path $profileDir jabba-upgrade.ps1)
2727

2828
# Alias
29-
Remove-Item Alias:cat
30-
Remove-Item -Force Alias:diff
31-
Remove-Item Alias:curl
29+
Remove-Alias cat
30+
Remove-Alias -Force diff
3231

3332
if (Test-Path (Join-Path $profileDir local_profile.ps1)) {
3433
. (Join-Path $profileDir local_profile.ps1)

PSReadlineProfile.ps1

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# This is an example profile for PSReadline.
2+
# This is an example profile for PSReadLine.
33
#
44
# This is roughly what I use so there is some emphasis on emacs bindings,
55
# but most of these bindings make sense in Windows mode as well.
@@ -21,14 +21,14 @@ Set-PSReadLineOption -HistoryNoDuplicates
2121
# when you used up arrow, which can be useful if you forget the exact
2222
# string you started the search on.
2323
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
24-
Set-PSReadlineKeyHandler -Key Ctrl+P -Function HistorySearchBackward
25-
Set-PSReadlineKeyHandler -Key Ctrl+N -Function HistorySearchForward
24+
Set-PSReadLineKeyHandler -Key Ctrl+p -Function HistorySearchBackward
25+
Set-PSReadLineKeyHandler -Key Ctrl+n -Function HistorySearchForward
2626

2727
# This key handler shows the entire or filtered history using Out-GridView. The
2828
# typed text is used as the substring pattern for filtering. A selected command
2929
# is inserted to the command line without invoking. Multiple command selection
3030
# is supported, e.g. selected by Ctrl + Click.
31-
Set-PSReadlineKeyHandler -Key F7 `
31+
Set-PSReadLineKeyHandler -Key F7 `
3232
-BriefDescription History `
3333
-LongDescription 'Show command history' `
3434
-ScriptBlock {
@@ -42,7 +42,7 @@ Set-PSReadlineKeyHandler -Key F7 `
4242
$history = [System.Collections.ArrayList]@(
4343
$last = ''
4444
$lines = ''
45-
foreach ($line in [System.IO.File]::ReadLines((Get-PSReadlineOption).HistorySavePath))
45+
foreach ($line in [System.IO.File]::ReadLines((Get-PSReadLineOption).HistorySavePath))
4646
{
4747
if ($line.EndsWith('`'))
4848
{
@@ -83,38 +83,38 @@ Set-PSReadlineKeyHandler -Key F7 `
8383

8484
# This is an example of a macro that you might use to execute a command.
8585
# This will add the command to history.
86-
Set-PSReadlineKeyHandler -Key Ctrl+B `
87-
-BriefDescription BuildCurrentDirectory `
88-
-LongDescription "Build the current directory" `
89-
-ScriptBlock {
90-
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
91-
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("msbuild")
92-
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
93-
}
86+
# Set-PSReadLineKeyHandler -Key Ctrl+b `
87+
# -BriefDescription BuildCurrentDirectory `
88+
# -LongDescription "Build the current directory" `
89+
# -ScriptBlock {
90+
# [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
91+
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert("msbuild")
92+
# [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
93+
# }
9494

9595
# In Emacs mode - Tab acts like in bash, but the Windows style completion
9696
# is still useful sometimes, so bind some keys so we can do both
97-
Set-PSReadlineKeyHandler -Key Ctrl+Q -Function TabCompleteNext
98-
Set-PSReadlineKeyHandler -Key Ctrl+Shift+Q -Function TabCompletePrevious
97+
Set-PSReadLineKeyHandler -Key Ctrl+q -Function TabCompleteNext
98+
Set-PSReadLineKeyHandler -Key Ctrl+Q -Function TabCompletePrevious
9999

100100
# Clipboard interaction is bound by default in Windows mode, but not Emacs mode.
101-
Set-PSReadlineKeyHandler -Key Shift+Ctrl+C -Function Copy
102-
Set-PSReadlineKeyHandler -Key Ctrl+V -Function Paste
101+
Set-PSReadLineKeyHandler -Key Shift+Ctrl+C -Function Copy
102+
Set-PSReadLineKeyHandler -Key Ctrl+V -Function Paste
103103

104104
# CaptureScreen is good for blog posts or email showing a transaction
105105
# of what you did when asking for help or demonstrating a technique.
106-
Set-PSReadlineKeyHandler -Chord 'Ctrl+D,Ctrl+C' -Function CaptureScreen
106+
Set-PSReadLineKeyHandler -Chord 'Ctrl+D,Ctrl+C' -Function CaptureScreen
107107

108108
# The built-in word movement uses character delimiters, but token based word
109109
# movement is also very useful - these are the bindings you'd use if you
110110
# prefer the token based movements bound to the normal emacs word movement
111111
# key bindings.
112-
Set-PSReadlineKeyHandler -Key Alt+D -Function ShellKillWord
113-
Set-PSReadlineKeyHandler -Key Alt+Backspace -Function ShellBackwardKillWord
114-
Set-PSReadlineKeyHandler -Key Alt+B -Function ShellBackwardWord
115-
Set-PSReadlineKeyHandler -Key Alt+F -Function ShellForwardWord
116-
Set-PSReadlineKeyHandler -Key Shift+Alt+B -Function SelectShellBackwardWord
117-
Set-PSReadlineKeyHandler -Key Shift+Alt+F -Function SelectShellForwardWord
112+
Set-PSReadLineKeyHandler -Key Alt+D -Function ShellKillWord
113+
Set-PSReadLineKeyHandler -Key Alt+Backspace -Function ShellBackwardKillWord
114+
Set-PSReadLineKeyHandler -Key Alt+B -Function ShellBackwardWord
115+
Set-PSReadLineKeyHandler -Key Alt+F -Function ShellForwardWord
116+
Set-PSReadLineKeyHandler -Key Shift+Alt+B -Function SelectShellBackwardWord
117+
Set-PSReadLineKeyHandler -Key Shift+Alt+F -Function SelectShellForwardWord
118118

119119
#region Smart Insert/Delete
120120

@@ -123,7 +123,7 @@ Set-PSReadlineKeyHandler -Key Shift+Alt+F -Function SelectShellForwardWord
123123
# in the module that do this, but this implementation still isn't as smart
124124
# as ReSharper, so I'm just providing it as a sample.
125125

126-
Set-PSReadlineKeyHandler -Key '"',"'" `
126+
Set-PSReadLineKeyHandler -Key '"',"'" `
127127
-BriefDescription SmartInsertQuote `
128128
-LongDescription "Insert paired quotes if not already on a quote" `
129129
-ScriptBlock {
@@ -145,7 +145,7 @@ Set-PSReadlineKeyHandler -Key '"',"'" `
145145
}
146146
}
147147

148-
Set-PSReadlineKeyHandler -Key '(','{','[' `
148+
Set-PSReadLineKeyHandler -Key '(','{','[' `
149149
-BriefDescription InsertPairedBraces `
150150
-LongDescription "Insert matching braces" `
151151
-ScriptBlock {
@@ -165,7 +165,7 @@ Set-PSReadlineKeyHandler -Key '(','{','[' `
165165
[Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor - 1)
166166
}
167167

168-
Set-PSReadlineKeyHandler -Key ')',']','}' `
168+
Set-PSReadLineKeyHandler -Key ')',']','}' `
169169
-BriefDescription SmartCloseBraces `
170170
-LongDescription "Insert closing brace or skip" `
171171
-ScriptBlock {
@@ -185,7 +185,7 @@ Set-PSReadlineKeyHandler -Key ')',']','}' `
185185
}
186186
}
187187

188-
Set-PSReadlineKeyHandler -Key Backspace `
188+
Set-PSReadLineKeyHandler -Key Backspace `
189189
-BriefDescription SmartBackspace `
190190
-LongDescription "Delete previous character or matching quotes/parens/braces" `
191191
-ScriptBlock {
@@ -227,7 +227,7 @@ Set-PSReadlineKeyHandler -Key Backspace `
227227
# This binding will let you save that command in the history so you can recall it,
228228
# but it doesn't actually execute. It also clears the line with RevertLine so the
229229
# undo stack is reset - though redo will still reconstruct the command line.
230-
Set-PSReadlineKeyHandler -Key Alt+w `
230+
Set-PSReadLineKeyHandler -Key Alt+w `
231231
-BriefDescription SaveInHistory `
232232
-LongDescription "Save current line in history but do not execute" `
233233
-ScriptBlock {
@@ -241,7 +241,7 @@ Set-PSReadlineKeyHandler -Key Alt+w `
241241
}
242242

243243
# Insert text from the clipboard as a here string
244-
Set-PSReadlineKeyHandler -Key Ctrl+Shift+v `
244+
Set-PSReadLineKeyHandler -Key Ctrl+Shift+v `
245245
-BriefDescription PasteAsHereString `
246246
-LongDescription "Paste the clipboard text as a here string" `
247247
-ScriptBlock {
@@ -263,7 +263,7 @@ Set-PSReadlineKeyHandler -Key Ctrl+Shift+v `
263263
# Sometimes you want to get a property of invoke a member on what you've entered so far
264264
# but you need parens to do that. This binding will help by putting parens around the current selection,
265265
# or if nothing is selected, the whole line.
266-
Set-PSReadlineKeyHandler -Key 'Alt+(' `
266+
Set-PSReadLineKeyHandler -Key 'Alt+(' `
267267
-BriefDescription ParenthesizeSelection `
268268
-LongDescription "Put parenthesis around the selection or entire line and move the cursor to after the closing parenthesis" `
269269
-ScriptBlock {
@@ -291,7 +291,7 @@ Set-PSReadlineKeyHandler -Key 'Alt+(' `
291291
# Each time you press Alt+', this key handler will change the token
292292
# under or before the cursor. It will cycle through single quotes, double quotes, or
293293
# no quotes each time it is invoked.
294-
Set-PSReadlineKeyHandler -Key "Alt+'" `
294+
Set-PSReadLineKeyHandler -Key "Alt+'" `
295295
-BriefDescription ToggleQuoteArgument `
296296
-LongDescription "Toggle quotes on the argument under the cursor" `
297297
-ScriptBlock {
@@ -353,7 +353,7 @@ Set-PSReadlineKeyHandler -Key "Alt+'" `
353353
}
354354

355355
# This example will replace any aliases on the command line with the resolved commands.
356-
Set-PSReadlineKeyHandler -Key "Alt+%" `
356+
Set-PSReadLineKeyHandler -Key "Alt+%" `
357357
-BriefDescription ExpandAliases `
358358
-LongDescription "Replace all aliases with the full command" `
359359
-ScriptBlock {
@@ -393,7 +393,7 @@ Set-PSReadlineKeyHandler -Key "Alt+%" `
393393
}
394394

395395
# F1 for help on the command line - naturally
396-
Set-PSReadlineKeyHandler -Key F1 `
396+
Set-PSReadLineKeyHandler -Key F1 `
397397
-BriefDescription CommandHelp `
398398
-LongDescription "Open the help window for the current command" `
399399
-ScriptBlock {
@@ -438,47 +438,47 @@ Set-PSReadlineKeyHandler -Key F1 `
438438
# needing to type cd and won't change the command line.
439439

440440
#
441-
$global:PSReadlineMarks = @{}
441+
$global:PSReadLineMarks = @{}
442442

443-
Set-PSReadlineKeyHandler -Key Ctrl+Shift+j `
443+
Set-PSReadLineKeyHandler -Key Ctrl+Shift+j `
444444
-BriefDescription MarkDirectory `
445445
-LongDescription "Mark the current directory" `
446446
-ScriptBlock {
447447
param($key, $arg)
448448

449449
$key = [Console]::ReadKey($true)
450-
$global:PSReadlineMarks[$key.KeyChar] = $pwd
450+
$global:PSReadLineMarks[$key.KeyChar] = $pwd
451451
}
452452

453-
Set-PSReadlineKeyHandler -Key Ctrl+j `
453+
Set-PSReadLineKeyHandler -Key Ctrl+j `
454454
-BriefDescription JumpDirectory `
455455
-LongDescription "Goto the marked directory" `
456456
-ScriptBlock {
457457
param($key, $arg)
458458

459459
$key = [Console]::ReadKey()
460-
$dir = $global:PSReadlineMarks[$key.KeyChar]
460+
$dir = $global:PSReadLineMarks[$key.KeyChar]
461461
if ($dir)
462462
{
463463
cd $dir
464464
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
465465
}
466466
}
467467

468-
Set-PSReadlineKeyHandler -Key Alt+j `
468+
Set-PSReadLineKeyHandler -Key Alt+j `
469469
-BriefDescription ShowDirectoryMarks `
470470
-LongDescription "Show the currently marked directories" `
471471
-ScriptBlock {
472472
param($key, $arg)
473473

474-
$global:PSReadlineMarks.GetEnumerator() | % {
474+
$global:PSReadLineMarks.GetEnumerator() | % {
475475
[PSCustomObject]@{Key = $_.Key; Dir = $_.Value} } |
476476
Format-Table -AutoSize | Out-Host
477477

478478
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
479479
}
480480

481-
Set-PSReadlineOption -CommandValidationHandler {
481+
Set-PSReadLineOption -CommandValidationHandler {
482482
param([System.Management.Automation.Language.CommandAst]$CommandAst)
483483

484484
switch ($CommandAst.GetCommandName())
@@ -497,7 +497,7 @@ Set-PSReadlineOption -CommandValidationHandler {
497497
}
498498

499499
# ghq + peco
500-
Set-PSReadlineKeyHandler -Key Ctrl+] `
500+
Set-PSReadLineKeyHandler -Key Ctrl+] `
501501
-BriefDescription SelectGHQDirectory `
502502
-LongDescription "Jump to the directory managed by ghq" `
503503
-ScriptBlock {

Pscx.UserPreferences.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
CD_EchoNewLocation = $false # Display new provider location after using cd (Set-LocationEx).
2323
# Mutually exclusive with CD_GetChildItem.
2424

25-
# TextEditor = 'Notepad.exe' # Default text editor used by the Edit-File function
26-
TextEditor = "$HOME\bin\micro.exe"
25+
TextEditor = 'Notepad.exe' # Default text editor used by the Edit-File function
2726

2827
PromptTheme = 'Modern' # Prompt string and window title updates. To enable, first
2928
# set the ModulesToImport setting for Prompt below to $true.

jabba-upgrade.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
function jabba-upgrade
33
{
44
Invoke-Expression (
5-
# Workaround URL until PS 6.0
6-
Invoke-WebRequest https://github.com/kxbmap/jabba/raw/ps-utf8/install.ps1 -UseBasicParsing
5+
Invoke-WebRequest https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing
76
).Content
87
}

setup.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
2-
powershell -ExecutionPolicy RemoteSigned -NoProfile -File %~dp0setup.ps1
2+
pwsh -ExecutionPolicy RemoteSigned -NoProfile -File %~dp0setup.ps1
33
pause

update-psreadline.bat

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)