Skip to content

A completion manager for better and simpler use completions in PowerShell. 一个补全管理模块,更简单、更方便的在 PowerShell 中使用命令补全。

License

Notifications You must be signed in to change notification settings

abgox/PSCompletions

Repository files navigation

✨PSCompletions(psc) ✨

English | 简体中文 | Github | Gitee

license code size repo size created


Introduce

  • PowerShell: A Cross-platform PowerShell. Start it in command line by running pwsh.

  • Windows PowerShell: A PowerShell which is built-in on Windows systems. Start it in command line by running powershell.


  • A completion manager in PowerShell for better and simpler use completions.

    It can also be used in Windows PowerShell.(Not Recommend)

  • Manage completions together.
  • Switch between languages(zh-CN,en-US...) freely.
  • Sort completion tab dynamically by frequency of use.

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

How to install

  1. Start PowerShell
  2. Install-Module PSCompletions -Scope CurrentUser
  3. Import-Module PSCompletions
    • echo "Import-Module PSCompletions" >> $PROFILE
    • So you don't have to import the module every time you open PowerShell.

How to uninstall

  1. Start PowerShell
  2. Uninstall-Module PSCompletions

How to use(e.g. git)

  • If it doesn't include the completion you want, you can submit an issue and I will consider adding it.
  1. psc add git
  2. Then you can enter git and press Space Tab to get command completion.
  3. For more commands on psc, you can learn by entering psc and then pressing Space Tab.

Demo

demo

Tips

About the completion trigger key

  • The module uses the Tab key by default.
  • You can set it by running Set-PSReadLineKeyHandler <key> MenuComplete.

About completion update

  • When the module is imported after opening PowerShell, PSCompletions 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

  • The module's completion menu provided by the module is based on PS-GuiCompletion realization idea, thanks!

  • It can only be used in PowerShell(pwsh) under Windows.

  • Some keys in the completion menu provided by the module.

    1. Apply the selected completion item: Enter

    2. Delete filter characters: Backspace

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

      • When there are no characters in the filter area, you can also use Backspace key to exit the completion menu.
    4. Select completion item:

      Select previous item Select next item
      Up Down
      Left Right
      Shift + Tab Tab
      Shift + Space Space
      Ctrl + u Ctrl + d
      Ctrl + p Ctrl + n
  • All configurations of it, you can trigger completion by running psc menu, then learn about them by completion tip.

About special symbols

  • 😄🤔😎 : If there are multiple, you can choose the effect of one of them.
    • 😄 : It means that after you apply it, you can press Space and Tab key to continue to get command completions.(Normal or optional completions)
      • It can be customized by running psc menu symbol SpaceTab <symbol>
    • 🤔 : It means that after you apply it (option completion), you can press Space and Tab key to continue to get option completions. (e.g. --verbose)
      • It can be customized by running psc menu symbol OptionTab <symbol>
    • 😎 : It means that after you apply it (option completion), you can enter a string, then press Space and Tab key to continue to get the rest of option completions.
      • If the string has Spaces, Please use "" or '' to wrap it. e.g. 'test content'
      • If there is also 😄, it means that there are some strings to complete, you can press Space and Tab key to continue to get command completions without entering a string.
      • It can be customized by running psc menu symbol WriteSpaceTab <symbol>
    • Completion of generic options can also be triggered if there is one or more generic option completion.
    • All complements can be triggered by pressing the Tab key after entering a part.
    • If you don't need or want to see these symbols, you can hide them by replacing them with the empty string.
      • e.g. psc menu symbol SpaceTab ""

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.
  • If the content matches this regex rule ^\.*[\\/].*, it will get the path completion, which is PowerShell completion.
  • 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.
  • So you can enter git add ./ and then press Tab key to get the path completion.

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
      • If it is greater than 100%, it means that the current language has some redundant completion items and should be cleaned.
    • Description: Command Description.
Completion Language Description
7z en-US
zh-CN(100%)
The command line cli of 7-Zip
bun en-US
zh-CN(100%)
Bun - JavaScript all-in-one toolkit
cargo en-US
zh-CN(100%)
cargo - Rust package manager
chfs en-US
zh-CN(100%)
CuteHttpFileServer - A free, HTTP protocol file sharing server cross-platform file sharing server
choco en-US
zh-CN(100%)
choco(chocolatey) - Software Manager
conda en-US
zh-CN(100%)
conda - binary package and environment manager
deno en-US
zh-CN(100%)
Deno - A secure runtime for JavaScript and TypeScript.
docker en-US
zh-CN(100%)
docker - Container Application Development
git en-US
zh-CN(100%)
Git - Version control system
kubectl en-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.
npm en-US
zh-CN(100%)
npm - package manager
nrm en-US
zh-CN(100%)
nrm - npm registry manager
nvm en-US
zh-CN(100%)
nvm - Node Version Manager
pip en-US
zh-CN(100%)
pip - Python Package Manager
pnpm en-US
zh-CN(94.23%)
pnpm - Package Manager
psc en-US
zh-CN(100%)
PSCompletions module's completion tips.
It can only be updated, not removed.
If removed, it will be automatically added again.
python en-US
zh-CN(100%)
python - command-line
scoop en-US
zh-CN(100%)
Scoop - Software Manager
volta en-US
zh-CN(100%)
volta - Accessible JavaScript Tool Manager
winget en-US
zh-CN(100%)
WinGet - Windows package manager
wsl en-US
zh-CN(100%)
WSL - Windows Subsystem for Linux
wt en-US
zh-CN(100%)
Windows terminal command line
yarn en-US
zh-CN(100%)
yarn - package manager
... ...                           ...

About

A completion manager for better and simpler use completions in PowerShell. 一个补全管理模块,更简单、更方便的在 PowerShell 中使用命令补全。

Topics

Resources

License

Stars

Watchers

Forks