Skip to content

Instantly share code, notes, and snippets.

@jethroo
Created November 13, 2024 08:53
Show Gist options
  • Select an option

  • Save jethroo/069acd96dbf19cb7fff763b4be870b7c to your computer and use it in GitHub Desktop.

Select an option

Save jethroo/069acd96dbf19cb7fff763b4be870b7c to your computer and use it in GitHub Desktop.
zsh git branch and dirty status
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
function parse_git_dirty {
[[ $(parse_git_branch) != "" ]] && [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "⚡️"
}
COLOR_DEF=$'%f'
COLOR_USR=$'%F{243}'
COLOR_DIR=$'%F{yellow}'
COLOR_GIT=$'%F{magenta}'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}$(parse_git_dirty)$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment