Skip to content

Add built-in PowerShell shell completion support#3637

Open
doctorlai-msrc wants to merge 2 commits into
pallets:mainfrom
doctorlai-msrc:zhihua/powershell
Open

Add built-in PowerShell shell completion support#3637
doctorlai-msrc wants to merge 2 commits into
pallets:mainfrom
doctorlai-msrc:zhihua/powershell

Conversation

@doctorlai-msrc

@doctorlai-msrc doctorlai-msrc commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Adds PowerShellComplete as a fourth built-in shell completer, alongside the
existing BashComplete, ZshComplete, and FishComplete. Users of Click-based
CLIs on Windows PowerShell 5.1+ or PowerShell (pwsh) 7+ can now opt into TAB
completion the same way they do for the other shells:

# In $PROFILE
$env:_FOO_BAR_COMPLETE = 'powershell_source'
foo-bar | Out-String | Invoke-Expression
Remove-Item Env:_FOO_BAR_COMPLETE

…or generate the script once and source it:

$env:_FOO_BAR_COMPLETE = 'powershell_source'
foo-bar | Out-File -Encoding utf8 ~/.foo-bar-complete.ps1
Remove-Item Env:_FOO_BAR_COMPLETE
# then in $PROFILE:
. ~/.foo-bar-complete.ps1

PowerShell support has been a long-standing gap in Click; downstream projects
have repeatedly worked around it by shipping ad-hoc completer scripts. This PR
makes it a first-class built-in so every Click-based CLI gets it for free.

@davidism davidism closed this Jun 26, 2026
@davidism davidism reopened this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants