Skip to content

Instantly share code, notes, and snippets.

@fdomig
Created November 4, 2014 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fdomig/010cc9ad3334f8a937b4 to your computer and use it in GitHub Desktop.
Save fdomig/010cc9ad3334f8a937b4 to your computer and use it in GitHub Desktop.
.bash_git
# 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