Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
Created October 7, 2021 22:10
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 kevinhooke/e4c80cdada0ca1cc866ce5948fe8de78 to your computer and use it in GitHub Desktop.
Save kevinhooke/e4c80cdada0ca1cc866ce5948fe8de78 to your computer and use it in GitHub Desktop.
MacOS zsh prompt customization for displaying git branch
#zsh git prompt customizations
parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment