From 965dcf5045d71134b8c587bb6208325a42d34727 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 8 Apr 2023 23:23:38 +0900 Subject: [PATCH] add & fix: pwsh: pip completion & completion load --- bin/windows/create_completion_files.ps1 | 1 + dotfiles/pwsh/powershell_profile.ps1 | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/windows/create_completion_files.ps1 b/bin/windows/create_completion_files.ps1 index 5019136..02ed1c3 100644 --- a/bin/windows/create_completion_files.ps1 +++ b/bin/windows/create_completion_files.ps1 @@ -13,6 +13,7 @@ rclone completion powershell > (Join-Path $script_location "rclone_completion.ps rustup completions powershell > (Join-Path $script_location "rustup_completion.ps1") wezterm shell-completion --shell power-shell > (Join-Path $script_location "wezterm_completion.ps1") chezmoi completion powershell > (Join-Path $script_location "chezmoi_completion.ps1") +pip completion --powershell > (Join-Path $script_location "pip_completion.ps1") # alias Set-Location $PSScriptRoot diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index d9ba332..9eb3984 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -190,6 +190,15 @@ Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock { } } +# PowerShell parameter completion shim for the dotnet CLI +# https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#powershell +Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock { + param($commandName, $wordToComplete, $cursorPosition) + dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object { + [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + } + } + # Import the Chocolatey Profile that contains the necessary code to enable # tab-completions to function for `choco`. # Be aware that if you are missing these lines from your profile, tab completion @@ -215,5 +224,5 @@ Import-Module npm-completion # wsl.exe Import-Module WSLTabCompletion -Get-ChildItem ~\.config\powershell\completions\ | % { & $_ } +Get-ChildItem ~\.config\powershell\completions\ | % { . $_ }