Created
November 4, 2014 11:22
-
-
Save fdomig/010cc9ad3334f8a937b4 to your computer and use it in GitHub Desktop.
.bash_git
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
# git funky stuff | |
red="$(tput setaf 1)" | |
green="$(tput setaf 2)" | |
NC="$(tput sgr0)" # No Color | |
branchcolor="" | |
branch="" | |
PS_ORIGINAL=$PS1 | |
function prompt_setup () | |
{ | |
branchdetect | |
PS1="\u@\h:\w\[$branchcolor\]$branch\[$NC\]\$ " | |
} | |
function branchdetect () | |
{ | |
branchcolor="" | |
branch="" | |
gitdetect | |
} | |
function gitdetect () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
gitver=$(__git_ps1) | |
if [[ $(git status 2> /dev/null | tail -n1) == "nothing to commit, working directory clean" ]] | |
then | |
branchcolor=$green | |
else | |
gitver=${gitver}'*' | |
branchcolor=$red | |
fi | |
branch="$gitver " | |
fi | |
} | |
PROMPT_COMMAND=prompt_setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment