Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created September 17, 2011 00:15
Show Gist options
  • Save nwjsmith/1223440 to your computer and use it in GitHub Desktop.
Save nwjsmith/1223440 to your computer and use it in GitHub Desktop.
commit_time ()
{
local repo=`git rev-parse --git-dir 2>/dev/null`
if [ -n "$repo" ]; then
local last=`git log --pretty=format:'%at' -1`
local now=`date +%s`
local m_since=0
((m_since=($now - $last) / 60))
local color=""
if [ $m_since -gt 60 ]; then
# Red
color="\033[0;31m"
elif [ $m_since -gt 30 ]; then
# Yellow
color="\033[0;33m"
else
# Green
color="\033[0;32m"
fi
printf "${1:-%b}" "${color}${m_since}\033[0m"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment