git completion and prompt under zsh
curl
scripts into config folder
mkdir $HOME/.config/zsh
cd $HOME/.config/zsh
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh -o _git
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -O
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O
# Git completions, status, and prompt
# See: https://git-scm.com/book/en/v2/Appendix-A:-Git-in-Other-Environments-Git-in-Zsh
autoload -Uz compinit && compinit
# See: $HOME/config/zsh/_git
fpath=($HOME/.config/zsh $fpath)
# uncomment if completions don't work:
# zstyle ':completion:*:*:git:*' script ~/.config/zsh/git-completion.bash
# Git status in prompt
# See: $HOME/config/zsh/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto verbose name git"
GIT_PS1_SHOWCOLORHINTS=1
GIT_PS1_STATESEPARATOR="|"
source $HOME/.config/zsh/git-prompt.sh
setopt PROMPT_SUBST
export PROMPT='%~ $(__git_ps1 "\n(枝%s)")
# Or for a more compact prompt, remove the linebreak (this is what I actually use):
# export PROMPT='%~ $(__git_ps1 "枝%s")
%# '
This is a very opinionated prompt, stacking 2-3 lines, showing only:
Why?
ssh
into another box, so username and hostname aren't needed.枝
is just for fun. It meansbranch
in both Chinese and Japanese.