- open
~/.zshrc
in TextEdit or any text editor - copy the snippet from mac-terminal-branch-color-zsh.md
- run
source ~/.zshrc
Created
March 9, 2024 21:53
-
-
Save albertho425/b40317891a050f803aa050ebfaa1e5ff to your computer and use it in GitHub Desktop.
Add branch and color to Mac terminal zsh in 2024
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF=$'%f'
COLOR_USR=$'%F{243}'
COLOR_DIR=$'%F{197}'
COLOR_GIT=$'%F{39}'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment