-
-
Save noeticpenguin/1428039 to your computer and use it in GitHub Desktop.
Blip prompt
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
# Prompt Setup | |
YELLOW='\[\033[1;33m\]' | |
BLUE='\[\033[1;34m\]' | |
GREEN='\[\033[1;32m\]' | |
RED='\[\033[0;31m\]' | |
NORMAL='\[\033[00m\]' | |
WHITE='\[\033[0;37m\]' | |
function minutes_since_last_commit { | |
now=`date +%s` | |
last_commit=`git log --pretty=format:'%at' -1` | |
seconds_since_last_commit=$((now-last_commit)) | |
minutes_since_last_commit=$((seconds_since_last_commit/60)) | |
echo $minutes_since_last_commit | |
} | |
function my_git_prompt() { | |
local g="$(__gitdir)" | |
if [ -n "$g" ]; then | |
local MINUTES_SINCE_LAST_COMMIT=`minutes_since_last_commit` | |
if [ "$MINUTES_SINCE_LAST_COMMIT" -gt 40 ]; then | |
local COLOR=${RED} | |
elif [ "$MINUTES_SINCE_LAST_COMMIT" -gt 15 ]; then | |
local COLOR=${YELLOW} | |
else | |
local COLOR=${GREEN} | |
fi | |
local SINCE_LAST_COMMIT="${COLOR}$(minutes_since_last_commit)m${NORMAL}" | |
local GIT_PROMPT=$(__git_ps1 "(%s|${SINCE_LAST_COMMIT})") | |
echo " ${GIT_PROMPT}" | |
fi | |
} | |
function exit_status_blip() { | |
if [ $? -eq 0 ]; then | |
local COLOR=${GREEN} | |
else | |
local COLOR=${RED} | |
fi | |
echo "${COLOR}•${NORMAL}" | |
} | |
function set_prompt() | |
{ | |
local BLIP="$(exit_status_blip)" | |
export PS1="${BLUE}\W${NORMAL}$(my_git_prompt) ${BLIP} " | |
} | |
PROMPT_COMMAND=set_prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment