# --- GIT BRANCH PROMPT ---
function git_branch_name()
{
branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
if [[ $branch == "" ]];
then
:
else
echo '- ('$branch')'
fi
}
# Enable substitution in the prompt.
setopt prompt_subst
COLOR_DEF=$'%f'
COLOR_DIR=$'%F{197}'
COLOR_GIT=$'%F{39}'
# Config for prompt. PS1 synonym.
prompt='${COLOR_DIR}%2/ ${COLOR_GIT}$(git_branch_name)${COLOR_DEF} $ '
# --- GIT BRANCH PROMPT ---
Forked from reinvanoyen/terminal-prompt-git-branch-zsh.md
Last active
January 23, 2024 18:18
-
-
Save lukestringer90/7c87c9bf13a8b90f8bb7ed15c2dd561c to your computer and use it in GitHub Desktop.
Add Git Branch Name to Terminal Prompt (MacOS Catalina zsh)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment