Created
November 28, 2011 15:13
-
-
Save tadasv/1400728 to your computer and use it in GitHub Desktop.
bash git 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
alias ls='ls -G' | |
c_cyan=`tput setaf 6` | |
c_red=`tput setaf 1` | |
c_green=`tput setaf 2` | |
c_sgr0=`tput sgr0` | |
parse_git_branch () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p') | |
else | |
return 0 | |
fi | |
echo -e $gitver | |
} | |
branch_color () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
color="" | |
if git diff --quiet 2>/dev/null >&2 | |
then | |
color="${c_green}" | |
else | |
color=${c_red} | |
fi | |
else | |
return 0 | |
fi | |
echo -ne $color | |
} | |
PS1='[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]] \u@\[${c_green}\]\h\[${c_sgr0}\] \[${c_red}\]\w\[${c_sgr0}\]: ' | |
## | |
# Your previous /Users/tadas/.bash_profile file was backed up as /Users/tadas/.bash_profile.macports-saved_2011-11-07_at_10:08:28 | |
## | |
# MacPorts Installer addition on 2011-11-07_at_10:08:28: adding an appropriate PATH variable for use with MacPorts. | |
export PATH=/opt/local/bin:/opt/local/sbin:$PATH | |
# Finished adapting your PATH environment variable for use with MacPorts. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment