Last active
January 3, 2016 14:09
-
-
Save chrislawlor/8474185 to your computer and use it in GitHub Desktop.
Bash prompt - add Git branch and 'dirty' status, e.g. user@localhost:~/code/project on develop⚡ Add to your ~/.bashrc (linux) or ~/.bash_profile (OSX)
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
# Custom prompt | |
function parse_git_dirty { | |
git branch > /dev/null 2>&1 | |
if [[ $(echo $?) == "0" ]] | |
then [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "⚡" | |
fi | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/on \1/" | |
} | |
export PS1='\e[0;32m\u@localhost:\w \e[0;35m$(parse_git_branch)\e[0;33m$(parse_git_dirty)\e[m\n$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment