-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt.bashrc
executable file
·45 lines (37 loc) · 1.03 KB
/
prompt.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Prompt Setup
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
YELLOW='\[\033[1;33m\]'
BLUE='\[\033[1;34m\]'
GREEN='\[\033[1;32m\]'
RED='\[\033[0;31m\]'
NORMAL='\[\033[00m\]'
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
}
git_prompt() {
# The __git_ps1 function inserts the current git branch where %s is
local GIT_BRANCH=`__git_ps1 "%s"`
local MINUTES_SINCE_LAST_COMMIT=`minutes_since_last_commit`
if [ "$MINUTES_SINCE_LAST_COMMIT" -gt 30 ]; then
local COLOR=${RED}
elif [ "$MINUTES_SINCE_LAST_COMMIT" -gt 10 ]; then
local COLOR=${YELLOW}
else
local COLOR=${GREEN}
fi
PS1="[\W] ${GIT_BRANCH} ${COLOR}${MINUTES_SINCE_LAST_COMMIT}m${NORMAL} $ "
}
set_prompt() {
local g="$(__gitdir)"
if [ -n "$g" ]; then
git_prompt
else
PS1="[\W] $ "
fi
}
PROMPT_COMMAND="set_prompt"