Skip to content

Instantly share code, notes, and snippets.

@tambakoo
Last active September 22, 2021 06:29
Show Gist options
  • Save tambakoo/d46708f94dbabc5e8b96db2c60968c56 to your computer and use it in GitHub Desktop.
Save tambakoo/d46708f94dbabc5e8b96db2c60968c56 to your computer and use it in GitHub Desktop.
Show git branch in a zsh terminal
#IN THE .zshrc DOTFILE, ADD THE FOLLOWING CODE
#git branch stuff
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/(\1)/p'
}
setopt PROMPT_SUBST
export PROMPT='${PWD} $(parse_git_branch) $ '
#RESULTS IN -
# /Users/himanshu/Desktop/commutatus/climber-api (develop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment