Created
April 14, 2011 09:39
-
-
Save wildjcrt/919198 to your computer and use it in GitHub Desktop.
.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
[ -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