Tested on macOS Monterey 12.3.1
Add the snippet below to the bottom of the file according to your terminal version.
iTerm
Edit ~/.bash_profile
Terminal
Edit ~/.zshrc
# Git branch in prompt.
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 '
Result
Top comments (0)