@@ -7,8 +7,8 @@ There are two ways of using `shtab`:
77 - end-users execute ` shtab your_cli_app.your_parser_object `
88- [ Library Usage] ( #library-usage ) : as a library integrated into your CLI application
99 - adds a couple of lines to your application
10- - argument mode: end-users execute ` your_cli_app --print-completion {bash,zsh,tcsh} `
11- - subparser mode: end-users execute ` your_cli_app completion {bash,zsh,tcsh} `
10+ - argument mode: end-users execute ` your_cli_app --print-completion {bash,zsh,tcsh,fish,powershell } `
11+ - subparser mode: end-users execute ` your_cli_app completion {bash,zsh,tcsh,fish,powershell } `
1212
1313## CLI Usage
1414
@@ -52,8 +52,8 @@ Below are various examples of enabling `shtab`'s own tab completion scripts.
5252
5353=== "zsh"
5454
55- Note that `zsh` requires completion script files to be named `_{EXECUTABLE}`
56- (with an underscore prefix).
55+ !!! info
56+ `zsh` requires completion script files to be named `_{EXECUTABLE}` (with an underscore prefix).
5757
5858 ```sh
5959 # note the underscore `_` prefix
@@ -103,6 +103,39 @@ Below are various examples of enabling `shtab`'s own tab completion scripts.
103103 | sudo tee /usr/share/fish/vendor_completions.d/shtab.fish
104104 ```
105105
106+ === "powershell"
107+
108+ !!! info
109+ PowerShell 7+ (`pwsh`) is fully supported, while
110+ Windows PowerShell 5 (`powershell.exe`) is only partially supported.
111+
112+ ```powershell
113+ New-Item -Path ~\.config\powershell\completions -ItemType Directory -Force
114+ shtab --shell=powershell shtab.main.get_main_parser --error-unimportable `
115+ | Out-File -FilePath ~\.config\powershell\completions\shtab.ps1
116+ # Add to $PROFILE:
117+ . ~\.config\powershell\completions\shtab.ps1
118+ ```
119+
120+ Eager:
121+
122+ Add the following to your PowerShell profile (`$PROFILE`):
123+
124+ ```powershell
125+ shtab --shell=powershell shtab.main.get_main_parser `
126+ | Out-String | Invoke-Expression
127+ ```
128+
129+ Or save to a file and dot-source it from your profile:
130+
131+ ```powershell
132+ New-Item -Path ~\.config\powershell\completions -ItemType Directory -Force
133+ shtab --shell=powershell shtab.main.get_main_parser `
134+ | Out-File -FilePath ~\.config\powershell\completions\shtab.ps1
135+ # Add to $PROFILE:
136+ . ~\.config\powershell\completions\shtab.ps1
137+ ```
138+
106139### argparse
107140
108141Any existing ` argparse ` -based scripts should be supported with minimal effort.
@@ -155,6 +188,15 @@ Assuming this code example is installed in `MY_PROG.cli`, simply run:
155188 | sudo tee /usr/share/fish/vendor_completions.d/MY-PROG.fish
156189 ```
157190
191+ === "powershell"
192+
193+ ```powershell
194+ New-Item -Path ~\.config\powershell\completions -ItemType Directory -Force
195+ shtab --shell=powershell -u MY_PROG.cli.get_main_parser `
196+ | Out-File -FilePath ~\.config\powershell\completions\MY-PROG.ps1
197+ . ~\.config\powershell\completions\MY-PROG.ps1
198+ ```
199+
158200### click
159201
160202Speedup ` click ` 's completions (and get support for more shell types) by changing from e.g. ` _MY_PROG_COMPLETE=bash_source MY-PROG ` to ` shtab MY_PROG.cli.main --prog MY-PROG -s bash `
0 commit comments