Created
January 21, 2019 20:37
-
-
Save mrmike/e7939d4370c57e16a36a79f7180297e0 to your computer and use it in GitHub Desktop.
.bash_profile
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://github.com/git/git/blob/master/contrib/completion/git-completion.bash | |
# bash-completion | |
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then | |
. /opt/local/etc/profile.d/bash_completion.sh | |
fi | |
# Git auto-completion | |
if [ -f ~/.git-completion.bash ]; then | |
. ~/.git-completion.bash | |
fi | |
c_cyan=`tput setaf 6` | |
c_red=`tput setaf 1` | |
c_green=`tput setaf 2` | |
c_light_red="$(tput setab 1)" | |
c_sgr0=`tput sgr0` | |
branch_color () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
color="" | |
# check if it is smoething not pushed in submodule | |
if (cd `git rev-parse --show-toplevel`; git submodule foreach git status) | grep "ahead" --quiet >/dev/null >&2 | |
then | |
color=${c_light_red} | |
else | |
# check if something is not commited | |
if git status | grep "clean" --quiet 2>/dev/null >&2 | |
then | |
#check if something is not pushed | |
if git status | grep "ahead" --quiet >/dev/null >&2 | |
then | |
color=${c_cyan} | |
else | |
color=${c_green} | |
fi | |
else | |
color=${c_red} | |
fi | |
fi | |
else | |
return 0 | |
fi | |
echo -n $color | |
} | |
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 | |
} | |
PS1='\u@\[${c_red}\]\w\[${c_sgr0}\]\[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment