-
Notifications
You must be signed in to change notification settings - Fork 5
Zsh
Simply do make install
, or manually copy the files:
cp git-completion.zsh ~/.local/share/git-completion/zsh/_git
cp git-completion.bash ~/.local/share/bash-completion/completions/git
cp git-prompt.sh ~/.local/share/git-completion/prompt.sh
Then edit ~/.zshrc
and add the following:
fpath=(~/.local/share/git-completion/zsh $fpath)
source ~/.local/share/git-completion/prompt.sh
You can use any location you want, if you already have a ~/.zsh
directory you can place the script there.
If you are using zinit, git-completion can be loaded as a plugin easily:
zinit light felipec/git-completion
git-completion is already bundled in oh-my-zsh as the gitfast
plugin, so just enable it:
plugins=(... gitfast)
GIT_COMPLETION_CHECKOUT_NO_GUESS=1 GIT_COMPLETION_SHOW_ALL=1
- GIT_COMPLETION_CHECKOUT_NO_GUESS
-
Do not include "DWIM" suggestions in git-checkout and git-switch completion.
- GIT_COMPLETION_SHOW_ALL
-
Suggest all options, including options which are typically hidden.
You need to add $(__git_ps1)
to your PS1, for example in ~/.zshrc
:
setopt PROMPT_SUBST
PS1='%m %~$(__git_ps1 "[%s]") %# '
If you want colors, simply add:
GIT_PS1_SHOWCOLORHINTS=1
For more options see Prompt.
By default aliases and custom commands are automatically handled, but you might have custom functions, for example:
glm() { git log ^master ${@:-HEAD} ; }
There’s no way for the completion to do the sensible thing here, unless you manually configure it.
You can use Zsh’s compdef
:
compdef _git glm=git_log