Created
April 24, 2013 09:02
-
-
Save johnnypez/5450775 to your computer and use it in GitHub Desktop.
shows cwd / user / git branch info in bash prompt
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
function parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /' | |
} | |
function get_git_color() { | |
isred=`git status -s 2> /dev/null | egrep "^.[^? ]" | wc | awk '{print $1}'` | |
isorange=`git status -s 2> /dev/null | egrep "^[^? ]" | wc | awk '{print $1}'` | |
git_prompt_color=32 | |
if [ $isorange -ne 0 ] | |
then | |
git_prompt_color=33 | |
fi | |
if [ $isred -ne 0 ] | |
then | |
git_prompt_color=31 | |
fi | |
echo "$git_prompt_color" | |
} | |
export PS1="\[\e[01;31m\]\w \u \[\e[1;\$(get_git_color)m\]\$(parse_git_branch) \[\e[01;31m\]$ \[\e[0m\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment