Skip to content

Instantly share code, notes, and snippets.

@imnaveensharma
Created June 20, 2022 10:51
Show Gist options
  • Save imnaveensharma/20a197b7f79254a34836cfdf5a213894 to your computer and use it in GitHub Desktop.
Save imnaveensharma/20a197b7f79254a34836cfdf5a213894 to your computer and use it in GitHub Desktop.
Git Branch Colors and Formatting on Terminal on Mac
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF='%f'
COLOR_USR='%F{0}'
COLOR_DIR='%F{197}'
COLOR_GIT='%F{39}'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
#export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '
#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