Skip to content

Instantly share code, notes, and snippets.

@wildjcrt
Created April 14, 2011 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wildjcrt/919198 to your computer and use it in GitHub Desktop.
Save wildjcrt/919198 to your computer and use it in GitHub Desktop.
.profile
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
[[ -s /Users/jcrt/.rvm/scripts/rvm ]] && source /Users/jcrt/.rvm/scripts/rvm
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
seconds_since_last_commit=$((now-last_commit));
minutes_since_last_commit=$((seconds_since_last_commit/60));
hours_since_last_commit=$((minutes_since_last_commit/60));
minutes_since_last_commit=$((minutes_since_last_commit%60));
echo "${hours_since_last_commit}h${minutes_since_last_commit}m ";
}
function parse_git_dirty {
D="$(git status 2> /dev/null | tail -n1 | awk '{ print $1$2 }' )"
if [ -z "$D" ] ; then
echo ""
elif [ "$D" == "nothingto" ] ; then
echo -e "(clear) : "
elif [ $D == "nothingadded" ] ; then
echo -e "(untracked) : "
elif [ "$D" == "nochanges" ] ; then
echo -e "(changed) : "
elif [ "$D" == "#" ]; then
echo -e "(staged) : "
else
echo -e "(untracked) : "
fi
}
PS1="\u:\[\033[1;32m\]\W\[\033[0m\] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\$(parse_git_dirty)$(git_since_last_commit)\[\033[0m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment