Skip to content

Instantly share code, notes, and snippets.

@phuochau
Created April 11, 2022 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phuochau/2b761ee84ff019674188143dcc13a293 to your computer and use it in GitHub Desktop.
Save phuochau/2b761ee84ff019674188143dcc13a293 to your computer and use it in GitHub Desktop.
Show Git branch in zsh (insert it into ~/.zshrc on Mac)
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
COLOR_DEF=$'\e[0m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '| %b'
# Set up the prompt (with git branch name)
setopt PROMPT_SUBST
PROMPT='${COLOR_DIR}%~ ${COLOR_GIT}${vcs_info_msg_0_} ${COLOR_DEF}$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment