简体中文 | English | Powershell Gallery | Github | Gitee
Star ⭐️ or Donate 💰 if you like it!
[!Tip]
PowerShell(pwsh)
: A cross-platform PowerShell. Start it by runningpwsh
/pwsh.exe
.Windows PowerShell
: A PowerShell which is built-in on Windows system. Start it by runningpowershell
/powershell.exe
.- They can both use
PSCompletions
, butPowerShell(pwsh)
is more recommended.
A completion manager for better and simpler use completions in PowerShell
.
en-US
,zh-CN
,…) freely.psc menu config
.[!Tip]
- If it cannot be displayed here, you can check it on the official website..
- Click to view the videos on Bilibili.
PowerShell
.Install module:
Import-Module PSCompletions
$PROFILE
to make it permanent by running the following command.
echo "Import-Module PSCompletions" >> $PROFILE
Import-Module PSCompletions
early in $PROFILE
to avoid the encoding issue.PowerShell
.Uninstall-Module PSCompletions
[!Tip]
- Available Completions.
- If it doesn’t include the completion you want, you can submit an issue.
- You can also combined with argc-completions.
Take git
as an example.
psc add git
git
, press Space
and Tab
key to get command completion.psc
, you just need to enter psc
, press Space
and Tab
key, and you will get all usages of psc
by reading the completion tip.PSCompletions
uses the Tab
key by default.psc menu config trigger_key <key>
.[!Warning]
- If you need to set
Set-PSReadLineKeyHandler -Key <key> -Function <MenuComplete|Complete>
- Please add it before
Import-Module PSCompletions
Example:
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete Import-Module PSCompletions
PSCompletions
module is imported after starting PowerShell
, it will start a background job to check for the completion status of the remote repository.PSCompletions
will show the latest status of the completions in the next time.Optional Completions
: some command completions that like -*
, such as --global
in git config --global
.git
as an example, if you want to enter git config user.name --global xxx
, you should use --global
completion first, and then use user.name
, and then enter the name xxx
.=
, if there’s completion definition, you can directly press the Tab
key to get the completions.In addition to the built-in completion menu of PowerShell
, PSCompletions
module also provides a more powerful completion menu.
psc menu config enable_menu 1
(Default: 1
)PowerShell
Windows PowerShell
Windows PowerShell
, the border style of the completion menu cannot be customized.
PowerShell
.Some keys in the module’s completion menu.
Enter
/ Space
Tab
when there’s only one completion.Backspace
Esc
/ Ctrl + c
Backspace
when there’re no characters in the filter area.Select completion item:
Select previous item | Select next item |
---|---|
Up |
Down |
Left |
Right |
Shift + Tab |
Tab |
Ctrl + u |
Ctrl + d |
Ctrl + p |
Ctrl + n |
psc menu
, then learn about them by the completion tip.
1
means true
and 0
means false
. (It applies to all configurations of PSCompletions
)psc menu config enable_enter_when_single 1
psc menu config enable_tip 0
psc menu config enable_prefix_match_in_filter 1
0
, fuzzy matching is used, and the *
and ?
wildcards are supported.psc menu config completion_suffix " "
psc menu config enable_menu_enhance 1
(Default: 1
)Now, PSCompletions
has two completion implementations.
Set-PSReadLineKeyHandler
enable_menu
and enable_menu_enhance
both set to 1
.Register-ArgumentCompleter
for all completions, which theoretically makes loading faster.TabExpansion2
to manage completions globally, not limited to those added by psc add
.
cd
/.\
/..\
/~\
/… in PowerShell
.Get-*
/Set-*
/New-*
/… in PowerShell
.Register-ArgumentCompleter
Register-ArgumentCompleter
psc menu config enable_menu_enhance 0
.psc add
.Set-PSReadLineKeyHandler -Key <key> -Function <MenuComplete|Complete>
.[!Tip]
- Due to future changes in Windows Terminal, 😄🤔😎 will not be displayed properly in the completion menu, so these three default special symbols will change.
- Related issue: https://github.com/microsoft/terminal/issues/18242
- The changes are as follows:
😄
=>~
🤔
=>?
😎
=>!
Special symbols after the completion item are used to let you know in advance if completions are available before you press the Tab
key.
psc add
.psc menu symbol SpaceTab ""
psc menu symbol OptionTab ""
psc menu symbol WriteSpaceTab ""
~
,?
,!
: If there are multiple, you can choose the effect of one of them.
Normal Completions
: Sub-commands. Such as add
/pull
/push
/commit
/… in git
.Optional Completions
: Optional parameters. Such as -g
/-u
/… in git add
.General Optional Completions
: General optional parameters that can be used with any command. Such as --help
/… in git
.Current Completions
: Current completion items in completion menu.~
: It means that after you apply it, you can press Space
and Tab
key to continue to get completions.
psc menu symbol SpaceTab <symbol>
?
: It means that after you apply it (Optional Completions
or General Optional Completions
), you can press Space
and Tab
key to continue to get Current Completions
.
psc menu symbol OptionTab <symbol>
!
: It means that after you apply it (Optional Completions
or General Optional Completions
), you can press Space
and enter a string, then press Space
and Tab
key to continue to get completions.
"
(quote) or '
(single quote) to wrap it. e.g. "test content"
~
, it means that there’s some preset completions, you can press Space
and Tab
key to continue to get them without entering a string.psc menu symbol WriteSpaceTab <symbol>
Tab
key after entering a part.The completion tip is only a helper, you can also disable the tip by running psc menu config enable_tip 0
psc menu config enable_tip 1
.psc
.
psc completion psc enable_tip 0
General structure of the completion tip: Usage
+ Description
+ Example
U: install|add [-g|-u] [options] <app>
This is a description of the command.
E: install xxx
add -g xxx
Example Analysis:
U:
install
add
<app>
app
is a simple summary of the parameters.-g
-u
[options]
: Some options.E:
Global language
: Default to the language of current system.
psc config language
.psc config language zh-CN
.Completion language
: The language set for the specified completion.
psc completion git language en-US
.Available language
: In the completion config.json
file, there is a language
attribute whose value is a list of available languages.Completion language
,use it.Global language
.Available language
.Available language
. (It’s usually en-US
)git
for example, when entering git add
, pressing the Space
and Tab
keys, path completion will not be triggered, only completion provided by the module will be triggered.^(?:\.\.?|~)?(?:[/\\]).*
../
or .\
and press Tab
key to get path completion for the subdirectory or file.../
or ..\
and press Tab
key to get path completion for the parent directory or file./
or \
and press Tab
key to get path completion for the sibling directory.~/
/ ../../
…git add ./
and then press Tab
key to get the path completion.