Simple ad-hoc git completion that works for me
Why not posh-git?
I couldn't figure out how to only get the completion to work, without loading the whole module, so I created my own that doesn't slow down your profile by ~0.5 seconds.
Also, this one tries to intelligently provide completions based on context, e.g.
git add <tab>
will provide a list of unstaged/modified files, while git switch <tab>
provides a list of branches to switch to, etc. They are added as
needed.
Install it either manually, or from PowershellGallery with:
Install-Module pwsh-git-completion
Later, register the completions with the function Register-GitCompletion
. Add
it to your profile to load the completion automatically.
This module does not support all git commands, but the ones I use most often myself. PRs are welcome to add support for more commands!
Currently, the module supports:
git <tab>
to complete commandsgit add <tab>
to complete unstaged filesgit rm <tab>
to complete removable filesgit restore <tab>
to complete modified, but non-staged, filesgit checkout <tab>
to complete potential refs to checkoutgit rebase <tab>
to complete potential refs to rebase upongit switch <tab>
to complete branches to switch togit any-command -<tab>
to complete flags for any command (completed by parsinggit help any-command
, some commands might be broken)
All completions also supports substring completions, e.g. git add .psm1<tab>
will complete
any unstaged files that has .psm1
in it's full path.
Probably the latest version of Powershell, or at least PSReadLine 2.1.0.