From 700fa0ba792a888801f06203a3fa1a927ef685b6 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 9 Oct 2022 20:42:38 +0900 Subject: [PATCH 1/3] update: pwsh: PSReadLine version & add CompletionPredictor --- dotfiles/pwsh/README.md | 3 ++- dotfiles/pwsh/powershell_profile.ps1 | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dotfiles/pwsh/README.md b/dotfiles/pwsh/README.md index fcd08ab..70c7973 100644 --- a/dotfiles/pwsh/README.md +++ b/dotfiles/pwsh/README.md @@ -2,6 +2,7 @@ some notable features ## Key-Bindings +- `F2` to toggle InlineView and ListView of predictions - tab completion like fish - `Ctrl + D` to exit - `Ctrl + G` to Invoke-FzfTabCompletion @@ -31,4 +32,4 @@ Especially useful for piping into linux commands like `less` - chezmoi - git - winget -- chocolatey \ No newline at end of file +- chocolatey diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index f1e3b7d..4a2982f 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -1,11 +1,12 @@ # ============================================================== # PSReadLine Settings # ============================================================== -Import-Module PSReadLine -Set-PSReadLineOption -PredictionSource History +Import-Module PSReadLine # >= 2.2.2 +Import-Module CompletionPredictor +Set-PSReadLineOption -PredictionSource HistoryAndPlugin # require PowerShell ≧ 7.2 and PSReadLine ≧ 2.2.2 Set-PSReadlineOption -HistoryNoDuplicates Set-PSReadLineOption -DingTone 880 # beep frequency -Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord # like fish +Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function AcceptSuggestion # like fish Set-PSReadLineKeyHandler -Chord "Tab" MenuComplete Set-PSReadLineKeyHandler -Chord "Ctrl+d" DeleteCharOrExit Set-PSReadLineKeyHandler -Chord "Ctrl+g" -ScriptBlock { Invoke-FzfTabCompletion } From 38928f1e21658d85604cbc0db395f184a1d8e677 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 10 Oct 2022 22:18:04 +0900 Subject: [PATCH 2/3] add: pwsh: emacs keybindings explicit cmd/pwsh PSReadLine mode --- dotfiles/pwsh/powershell_profile.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index 4a2982f..ea5f655 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -3,13 +3,17 @@ # ============================================================== Import-Module PSReadLine # >= 2.2.2 Import-Module CompletionPredictor +Set-PSReadLineOption -EditMode Windows Set-PSReadLineOption -PredictionSource HistoryAndPlugin # require PowerShell ≧ 7.2 and PSReadLine ≧ 2.2.2 Set-PSReadlineOption -HistoryNoDuplicates Set-PSReadLineOption -DingTone 880 # beep frequency +Set-PSReadLineKeyHandler -Chord "Ctrl+u" -Function BackwardKillInput # like emacs +Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function PreviousHistory # like emacs +Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function NextHistory # like emacs Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function AcceptSuggestion # like fish Set-PSReadLineKeyHandler -Chord "Tab" MenuComplete Set-PSReadLineKeyHandler -Chord "Ctrl+d" DeleteCharOrExit -Set-PSReadLineKeyHandler -Chord "Ctrl+g" -ScriptBlock { Invoke-FzfTabCompletion } +Set-PSReadLineKeyHandler -Chord "Ctrl+g" -ScriptBlock { Invoke-FzfTabCompletion } -BriefDescription "Fzf tab completion" -Description "Invoke fzf tab completion. Need some input first." # PsFzf Options # 'Ctrl+t' for provider path, 'Ctrl+r' for reverse history From 9e9782357ebccb268bdb4d9caf212dfaa1451ae4 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 11 Oct 2022 18:43:32 +0900 Subject: [PATCH 3/3] update: pwsh: module installs (now use ZLocation instead of z to improve tab completion) --- bin/install.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/install.ps1 b/bin/install.ps1 index 72cda8c..0aa87d8 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -26,8 +26,15 @@ Install-Module -Name posh-git Write-Output "Pscx" Install-Module -Name Pscx -AllowPrerelease Write-Output "z" -Install-Module -Name z +Install-Module -Name ZLocation +Write-Output "PSFzf" Install-Module -Name PSFzf -RequiredVersion 2.5.10 +Write-Output "Latest PSReadLine" +Install-Module -Name PSReadLine -Force # Override default version to get the latest one +Write-Output "CompletionPredictor" +Install-Module -Name CompletionPredictor + + # install scoop if(!(Get-Command scoop -ErrorAction SilentlyContinue)) {