Created
November 13, 2024 08:53
-
-
Save jethroo/069acd96dbf19cb7fff763b4be870b7c to your computer and use it in GitHub Desktop.
zsh git branch and dirty status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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