Last active
December 5, 2019 20:35
-
-
Save mfts/2bf98f68a40703a9cbaaa20f1c5611ec to your computer and use it in GitHub Desktop.
Zsh Prompt to show dirty and clean status of git branch
This file contains 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
autoload -U colors && colors | |
setopt prompt_subst | |
# Get branch and open commits in prompt | |
function git-dirty() { | |
[[ $(git status 2>/dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*" | |
} | |
function parse_git_branch() { | |
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/ (\1$(git-dirty))/" | |
} | |
# Color for the zsh prompt (including git function) | |
PROMPT='%F{057}%n%f@%F{118}%m:%B%F{190}%~%b%F{021}$(parse_git_branch)%f $ ' |
Author
mfts
commented
Dec 5, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment