Skip to content

Instantly share code, notes, and snippets.

@yuv4ik
Last active March 18, 2022 12:30
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 yuv4ik/668d0411b4f088cea9b030bf05255908 to your computer and use it in GitHub Desktop.
Save yuv4ik/668d0411b4f088cea9b030bf05255908 to your computer and use it in GitHub Desktop.
macOS Catalina: show git branch in terminal
  • Create a .zshrc file if it does not exist using the next command:
    touch ~/.zshrc
  • Open ~/.zshrc and add the next content:
# git branch
function parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}

setopt PROMPT_SUBST
export PROMPT='%F{grey}%n%f %F{cyan}%~%f %F{green}$(parse_git_branch)%f %F{normal}$%f '
  • Use the next command to activate the change in already opened terminal:
    source ~/.zshrc

Big thanks to the orignal thread.

@JordanDalton
Copy link

Thanks!

@rafaelps1
Copy link

Show!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment