· From Making sense of zsh
A small and neat zsh configuration to enable Git autocompletion and customize the prompt.
autoload -Uz compinit && compinit
autoload -Uz vcs_info
precmd() { vcs_info }
setopt PROMPT_SUBST
zstyle ':vcs_info:git:*' formats '%F{153}%b%f'
PROMPT='%(?.%F{green}●.%F{red}●%f) %F{211}%1~%f ${vcs_info_msg_0_} '
RPROMPT='%F{245}%*%f'
If you want to make sense of the PROMPT
variable, here is a commented out version:
# %( ) ternary expression
# ? result of the previous command
# . . ternary separators
# %F{green} %F{red} %F{211} text color codes
# ● ● bullet character
# %f %f text color reset
# %1~ current directory
# ${vcs_info_msg_0_} VCS branch name
PROMPT='%(?.%F{green}●.%F{red}●%f) %F{211}%1~%f ${vcs_info_msg_0_} '