Skip to content

Instantly share code, notes, and snippets.

@dkowis
Created March 2, 2013 00:04
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 dkowis/5068928 to your computer and use it in GitHub Desktop.
Save dkowis/5068928 to your computer and use it in GitHub Desktop.
Handy Git stuff
# git shell stuff of awesomeness
# do cool color things with the shell line
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if /usr/bin/git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(/usr/bin/git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
else
return 0
fi
echo -e $gitver
}
branch_color ()
{
if /usr/bin/git rev-parse --git-dir >/dev/null 2>&1
then
color=""
if /usr/bin/git diff --quiet 2>/dev/null >&2
then
color="${c_green}"
else
color=${c_red}
fi
else
return 0
fi
echo -ne $color
}
# a function that wraps rvm-prompt in some colors! and I can add it to my PS1 HOORAYS
current_rvm() {
local RVM=`which rvm 2>/dev/null`
if [ -x "$RVM" ]; then
echo -ne "\e[37;44m$(rvm-prompt)\e[0m"
fi
}
export PS1='\t|\e[0;29m\u\e[0;29m@\e[0;36m\h \e[0;29m\W $(branch_color)$(parse_git_branch)\e[0;29m $(current_rvm)\n$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment