Last active
August 29, 2015 14:07
-
-
Save nomisoft/f50aae637242a4af6f70 to your computer and use it in GitHub Desktop.
Git Colourized Status in Terminal
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
# Add the branch name to the end of the path in the terminal and colour code it depending on git status | |
# Add the following to the end of .bashrc in your home directory | |
parse_git_colour() { | |
if [[ $(git status 2> /dev/null) =~ "nothing to commit" ]]; then | |
echo -ne "\033[0;33m" | |
else | |
echo -ne "\033[0;31m" | |
fi | |
} | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
PS1="${debian_chroot:+($debian_chroot)}\[\033[0;34m\]\u@\h:\[\033[0;32m\]\w\[\$(parse_git_colour)\]\$(parse_git_branch)\[\033[00m\]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment