Cleanup profile and enable tab completion menu

This commit is contained in:
Kenneth Benzie 2022-07-03 11:09:18 +01:00
parent 0a9f004dc9
commit 08b543f7fc

View File

@ -1,5 +1,5 @@
# Use Cmder's multiline prompt and posh-git. # Use Cmder's multiline prompt and posh-git.
Import-Module "$env:ChocolateyToolsLocation\\Cmder\\vendor\\profile.ps1" Import-Module "$env:ChocolateyToolsLocation\Cmder\vendor\profile.ps1"
# Enable Chocolatey completions. # Enable Chocolatey completions.
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
@ -12,16 +12,15 @@ $OutputEncoding = New-Object -typename System.Text.UTF8Encoding
Set-PSReadLineOption -BellStyle None -EditMode Vi Set-PSReadLineOption -BellStyle None -EditMode Vi
# Make C-w backward delete a word. # Make C-w backward delete a word.
Set-PSReadLineKeyHandler -Chord Ctrl+w -Function BackwardDeleteWord Set-PSReadLineKeyHandler -Chord Ctrl+w -Function BackwardDeleteWord
# TODO: Doesn't work with PSReadLine 2.1 # Make C-[ escape insert mode.
# Hoping this gets fixed at some point and will just start working. # https://github.com/PowerShell/PSReadLine/issues/906#issuecomment-916847040
# Set-PSReadLineKeyHandler -Chord Ctrl+[ -Function ViCommandMode
# Workaournd from https://github.com/PowerShell/PSReadLine/issues/906#issuecomment-916847040
Set-PSReadLineKeyHandler -Chord 'Ctrl+Oem4' -Function ViCommandMode Set-PSReadLineKeyHandler -Chord 'Ctrl+Oem4' -Function ViCommandMode
# Enable menu style tab completions. https://stackoverflow.com/a/37715242
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Change cursor shape based on what Vi mode the line editor is in. # Change cursor shape based on what Vi mode the line editor is in.
# Testing and works with PowerShell 5.1 # Tested and works with PowerShell 5.1
# NOTE: Requires: Install-Module PsReadline -Scope CurrentUser -Force # NOTE: Requires: Install-Module PsReadline -Scope CurrentUser -Force
# FIXME: Doesn't work with PSReadLine 2.0
function OnViModeChange { function OnViModeChange {
if ($args[0] -eq 'Command') { if ($args[0] -eq 'Command') {
# Set the cursor to non-blinking block. # Set the cursor to non-blinking block.