PSCompletions

0

A completion manager for better and simpler use and Manage completions.(一个补全管理模块,更好、更简单、更方便的使用和管理补全)

Productivity

module
powershell
ps
completions

PSCompletions(psc)

简体中文 | English | Github | Gitee

license module version PowerShell Gallery code size repo size created


Introduce

  • PowerShell: A cross-platform PowerShell. Start it by running pwsh/pwsh.exe.

  • Windows PowerShell: A PowerShell which is built-in on Windows system. Start it by running powershell/powershell.exe.


If PSCompletions is helpful to you, please consider giving it a star ⭐.

What's new

FAQ

How to install

  1. Start PowerShell.

  2. Install module:

    • Don't omit -Scope CurrentUser unless you're sure you'll always start PowerShell with administrator permissions.
      Install-Module PSCompletions -Scope CurrentUser
      
    • Install silently:
      Install-Module PSCompletions -Scope CurrentUser -Repository PSGallery -Force
      
  3. Import module:

    Import-Module PSCompletions
    
    • If you don't want to import the PSCompletions module every time when you start PowerShell, you can write it to $PROFILE.
      echo "Import-Module PSCompletions" >> $PROFILE
      

How to uninstall

  1. Start PowerShell.
  2. Uninstall module:
    Uninstall-Module PSCompletions
    

How to use

Available Completions

If it doesn't include the completion you want, you can submit an issue.

  • Take git as an example.
  1. psc add git
  2. Then you can enter git, press Space and Tab key to get command completion.
  3. For more usages on 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.

Demo

demo

Contribution

Tips

About the completion trigger key

  • PSCompletions uses the Tab key by default.
  • You can set it by running psc menu config trigger_key <key>.

About completion update

  • When PSCompletions module is imported after starting PowerShell, it will start a background job to check for the completion status of the remote repository.
  • After getting the update, PSCompletions will show the latest status of the completions in the next time.

About completion menu

  • In addition to the built-in completion menu of PowerShell, PSCompletions module also provides a more powerful completion menu.

    • Setting: psc menu config enable_menu 1 (Default: 1)
  • The module's completion menu is based on PS-GuiCompletion realization idea, thanks!

  • Available Windows environment:

    • PowerShell v4.0.0+ support
    • Windows PowerShell v4.1.0+ support
      • Due to rendering problems of Windows PowerShell, the border style of the completion menu cannot be customized.
        • If you need to customize it, use PowerShell.
  • Some keys in the module's completion menu.

    1. Apply the selected completion item: Enter

      • You can also use Tab or Space when there's only one completion.
    2. Delete filter characters: Backspace

    3. Exit the completion menu: Esc / Ctrl + c

      • You can also use Backspace when there're no characters in the filter area.
    4. Select completion item:

      Select previous itemSelect next item
      UpDown
      LeftRight
      Shift + TabTab
      Shift + SpaceSpace
      Ctrl + uCtrl + d
      Ctrl + pCtrl + n
  • All configurations of it, you can trigger completion by running psc menu, then learn about them by the completion tip.

    • For configured values, 1 means true and 0 means false. (It applies to all configurations of PSCompletions)

About menu enhance v4.2.0+ support

  • Setting: psc menu config enable_menu_enhance 1 (Default: 1)

  • Now, PSCompletions has two completion implementations.

    1. Register-ArgumentCompleter
      • v4.1.0 support : It's used.
      • v4.2.0+ support: It's optional.
        • You can use it by running psc menu config enable_menu_enhance 0.
        • It's not recommended. It only works for completions added by psc add.
    2. Set-PSReadLineKeyHandler
      • v4.2.0+ support: It's used by default.
        • Requires: enable_menu and enable_menu_enhance both set to 1.
      • It no longer needs to loop through registering Register-ArgumentCompleter for all completions, which theoretically makes loading faster.
      • It use TabExpansion2 to manage completions globally, not limited to those added by psc add.
        • For example:
          • Path completion such as cd/.\/..\/~\/... in PowerShell.
          • Build-in commands such as Get-*/Set-*/New-*/... in PowerShell.
          • Completion registered by Register-ArgumentCompleter
          • Completion registered by cli or module.
          • ...

About special symbols

  • Special symbols after the completion item are used to let you know in advance if completions are available before you press the Tab key.

    • If you don't need or want to see these symbols, you can hide them by replacing them with the empty string.
      • 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.

    • Define them:
      • Normal Completion: Sub-commands. Such as add/pull/push/commit/... in git.
      • Optional Completion: Optional parameters. Such as -g/-u/... in git add.
      • General Optional Completion: General optional parameters that can be used with any command. Such as --help/... in git.
    • 😄 : It means that after you apply it, you can press Space and Tab key to continue to get Normal Completion or Optional Completion.
      • It will appear only when there's Normal Completion or Optional Completion.
      • It can be customized by running psc menu symbol SpaceTab <symbol>
    • 🤔 : It means that after you apply it (Optional Completion), you can press Space and Tab key to continue to get other Optional Completion.
      • General Optional Completion use also this symbol.
      • It can be customized by running psc menu symbol OptionTab <symbol>
    • 😎 : It means that after you apply it (Optional Completion or General Optional Completion), you can press Space and enter a string, then press Space and Tab key to continue to get other Optional Completion or General Optional Completion.
      • If the string has Spaces, Please use "(quote) or '(single quote) to wrap it. e.g. "test content"
      • If there's also 😄, it means that there's Normal Completion, you can press Space and Tab key to continue to get them without entering a string.
      • It can be customized by running psc menu symbol WriteSpaceTab <symbol>
    • All completions can be triggered by pressing the Tab key after entering a part.

About completion tip

  • The completion tip is only a helper, you can also disable the tip by running psc menu config enable_tip 0

    • To enable the completion tip, run psc menu config enable_tip 1.
    • You can also disable the tip for a specific completion, such as 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:

    1. Usage: Begin with U:
      • command name: install
      • command alias: add
      • required parameters: <app>
        • app is a simple summary of the parameters.
      • optional parameters: -g -u
        • [options]: Some options.
    2. Description: The description of the command.
    3. Example: Begin with E:

About language

  • Global language: Default to the language of current system.
    • You can show it by running psc config language.
    • You can change it by running psc config language zh-CN.
  • Completion language: The language set for the specified completion.
    • e.g. 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.

Determine language

  1. Get the specified language:
    • If there is Completion language,use it.
    • If not, use Global language.
  2. Determine the final language:
    • Determine whether the value of the first step exists in Available language.
    • If it exists, use it.
    • If not, use the first of the Available language. (It's usually en-US)

About path completion

  • Take 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.
  • If you want to trigger path completion, you need to enter a content which matches ^(?:\.\.?|~)?(?:[/\\]).*.
  • e.g.
    • Please enter ./ or .\ and press Tab key to get path completion for the subdirectory or file.
    • Please enter ../ or ..\ and press Tab key to get path completion for the parent directory or file.
    • Please enter / or \ and press Tab key to get path completion for the sibling directory.
    • More examples: ~/ / ../../ ...
  • So you can enter git add ./ and then press Tab key to get the path completion.

Support

Support

Available Completions List

  • Guide
    • Completion :Click to view to the official website of the command. Sort by first letter(0-9,a-z).
      • Special case: abc(a), it means that you need to download it by psc add abc, but by default a is used instead of abc to trigger the completion.
    • Language: Supported Languages, and Translation Progress.
      • The translation progress is compared to en-US.
    • Description: Command Description.
CompletionLanguageDescription
7zen-US
zh-CN(100%)
The command line cli of 7-Zip
archen-US
zh-CN(100%)
Display machine architecture.
Come from uutils/coreutils
b2sumen-US
zh-CN(15.38%)
Compute and check message digests.
Come from uutils/coreutils
b3sumen-US
zh-CN(15.38%)
Compute and check message digests.
Come from uutils/coreutils
base32en-US
zh-CN(33.33%)
Encode/decode data and print to standard output.
Come from uutils/coreutils
base64en-US
zh-CN(33.33%)
Encode/decode data and print to standard output.
Come from uutils/coreutils
basenameen-US
zh-CN(33.33%)
Print NAME with any leading directory components removed.
Come from uutils/coreutils
basencen-US
zh-CN(18.18%)
Encode/decode data and print to standard output.
Come from uutils/coreutils
bunen-US
zh-CN(100%)
Bun - JavaScript all-in-one toolkit
cargoen-US
zh-CN(100%)
cargo - Rust package manager
chfsen-US
zh-CN(100%)
CuteHttpFileServer - A free, HTTP protocol file sharing server cross-platform file sharing server
chocoen-US
zh-CN(100%)
choco(chocolatey) - Software Manager
cksumen-US
zh-CN(17.14%)
Print CRC and size for each file.
Come from uutils/coreutils
commen-US
zh-CN(27.27%)
Compare two sorted files line by line.
Come from uutils/coreutils
condaen-US
zh-CN(100%)
conda - binary package and environment manager
cspliten-US
zh-CN(19.35%)
Split a file into sections determined by context lines.
Come from uutils/coreutils
cuten-US
zh-CN(16.22%)
Print specified byte or field columns from each line of stdin or the input files.
Come from uutils/coreutils
dateen-US
zh-CN(14.29%)
Print or set the system date and time.
Come from uutils/coreutils
dden-US
zh-CN(100%)
Copy, and optionally convert, a file system resource.
Come from uutils/coreutils
denoen-US
zh-CN(100%)
Deno - A secure runtime for JavaScript and TypeScript.
dfen-US
zh-CN(6.67%)
Show information about the file system on which each FILE resides, or all file systems by default.
Come from uutils/coreutils
dircolorsen-US
zh-CN(31.58%)
Output commands to set the LS_COLORS environment variable.
Come from uutils/coreutils
dirnameen-US
zh-CN(54.55%)
Strip last component from file name.
Come from uutils/coreutils
dockeren-US
zh-CN(100%)
docker - Container Application Development
duen-US
zh-CN(5.83%)
Estimate file space usage.
Come from uutils/coreutils
enven-US
zh-CN(16.67%)
Set each NAME to VALUE in the environment and run COMMAND.
Come from uutils/coreutils
factoren-US
zh-CN(60%)
Print the prime factors of the given NUMBER(s).
Come from uutils/coreutils
fmten-US
zh-CN(14.63%)
Reformat paragraphs from input files (or stdin) to stdout.
Come from uutils/coreutils
fnmen-US
zh-CN(14.52%)
Fast and simple Node.js version manager, built in Rust.
folden-US
zh-CN(33.33%)
Writes each file (or standard input if no files are given) to standard output whilst breaking long lines.
Come from uutils/coreutils
giten-US
zh-CN(100%)
Git - Version control system
hashsumen-US
zh-CN(8.57%)
Compute and check message digests.
Come from uutils/coreutils
headen-US
zh-CN(24%)
Print the first 10 lines of each 'FILE' to standard output.
Come from uutils/coreutils
joinen-US
zh-CN(13.04%)
For each pair of input lines with identical join fields, write a line to standard output.
The default join field is the first, delimited by blanks.
Come from uutils/coreutils
kubectlen-US
zh-CN(100%)
Kubernetes, also known as K8s, is an open source system for automating deployment, scaling, and management of containerized applications.
kubectl is its command-line tool.
linken-US
zh-CN(100%)
Call the link function to create a link named FILE2 to an existing FILE1.
Come from uutils/coreutils
lnen-US
zh-CN(14.63%)
Make links between files.
Come from uutils/coreutils
md5sumen-US
zh-CN(17.14%)
Compute and check message digests.
Come from uutils/coreutils
mktempen-US
zh-CN(24%)
Create a temporary file or directory.
Come from uutils/coreutils
ngroken-US
zh-CN(100%)
ngrok - Unified Ingress Platform for developers.
Connect localhost to the internet for testing applications and APIs.
nlen-US
zh-CN(6.58%)
Number lines of files.
Come from uutils/coreutils
npmen-US
zh-CN(100%)
npm - package manager
nprocen-US
zh-CN(46.15%)
Print the number of cores available to the current process.
Come from uutils/coreutils
nrmen-US
zh-CN(100%)
nrm - npm registry manager
numfmten-US
zh-CN(8.57%)
Convert numbers from/to human-readable strings.
Come from uutils/coreutils
nvmen-US
zh-CN(100%)
nvm - Node Version Manager
oden-US
zh-CN(7.41%)
Dump files in octal and other formats.
Come from uutils/coreutils
pasteen-US
zh-CN(33.33%)
Write lines consisting of the sequentially corresponding lines from each 'FILE', separated by 'TAB's, to standard output.
Come from uutils/coreutils
pdmen-US
zh-CN(0.82%)
A modern Python package and dependency manager supporting the latest PEP standards
pipen-US
zh-CN(100%)
pip - Python Package Manager
pnpmen-US
zh-CN(100%)
pnpm - Package Manager
powershellen-US
zh-CN(100%)
Windows PowerShell CLI. (powershell.exe)
pscen-US
zh-CN(100%)
PSCompletions module's completion tips.
It can only be updated, not removed.
If removed, it will be automatically added again.
pwshen-US
zh-CN(100%)
PowerShell CLI. (pwsh.exe)
pythonen-US
zh-CN(100%)
python - command-line
scoopen-US
zh-CN(100%)
Scoop - Software Manager
sfsuen-US
zh-CN(10.77%)
Scoop utilities that can replace the slowest parts of Scoop, and run anywhere from 30-100 times faster
voltaen-US
zh-CN(100%)
volta - Accessible JavaScript Tool Manager
wingeten-US
zh-CN(100%)
WinGet - Windows package manager
wslen-US
zh-CN(100%)
WSL - Windows Subsystem for Linux
wten-US
zh-CN(100%)
Windows Terminal command line.
You can use it to start a terminal.
yarnen-US
zh-CN(100%)
yarn - package manager
......                          ...