- 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.
Thanks!