Skip to content

Instantly share code, notes, and snippets.

@mfts
Last active December 5, 2019 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfts/2bf98f68a40703a9cbaaa20f1c5611ec to your computer and use it in GitHub Desktop.
Save mfts/2bf98f68a40703a9cbaaa20f1c5611ec to your computer and use it in GitHub Desktop.
Zsh Prompt to show dirty and clean status of git branch
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 $ '
@mfts
Copy link
Author

mfts commented Dec 5, 2019

Screenshot 2019-12-05 at 21 30 57

@mfts
Copy link
Author

mfts commented Dec 5, 2019

3 digit color scheme can be found here

UQVe5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment