Created
May 6, 2017 22:33
-
-
Save nealfennimore/06bed71455b9e8e05c6ba735796afec1 to your computer and use it in GitHub Desktop.
Terminal git branch state
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
# https://gist.github.com/chrisnolet/d07a55580337cfe7d5388b1d3c4960cc | |
function git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (*\([^)]*\))*/\1/' | |
} | |
function markup_git_branch { | |
if [[ -n $@ ]]; then | |
if [[ -z $(git status --porcelain 2> /dev/null | tail -n1) ]]; then | |
echo -e " \001\033[32m\002($@)\001\033[0m\002" | |
else | |
echo -e " \001\033[31m\002($@)\001\033[0m\002" | |
fi | |
fi | |
} | |
PS1="\$(markup_git_branch \$(git_branch))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment