Created
December 20, 2011 03:48
-
-
Save hSATAC/1500143 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
| 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 "; | |
| } | |
| unset temp | |
| function prompt_command { | |
| if [ "$HOME" == "$PWD" ] | |
| then | |
| newPWD="~" | |
| elif [ "$HOME" == "${PWD:0:${#HOME}}" ] | |
| then | |
| newPWD="~${PWD:${#HOME}}" | |
| else | |
| newPWD=$PWD | |
| fi | |
| TERMWIDTH=${COLUMNS} | |
| local temp="→ [ ${newPWD} ] $(git_branch)$(git_since_last_commit)" | |
| let fillsize=${TERMWIDTH}-${#temp} | |
| if [ "$fillsize" -gt "0" ] | |
| then | |
| fill="----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" | |
| fill="${fill:0:${fillsize}}" | |
| fi | |
| } | |
| PROMPT_COMMAND=prompt_command | |
| PS1="\[\033[1;31m\]→\[\033[0m\] \[\033[0;36m\][ \[\033[1;32m\]\${newPWD}\[\033[0;36m\] ] \[\033[0m\]\[\033[1;31m\]\$(git_branch)\[\033[0m\]\$(git_since_last_commit)\${fill}\n$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment