Created
September 17, 2011 00:15
-
-
Save nwjsmith/1223440 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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