Merge branch 'master' of https://github.com/Soliah/oh-my-zsh into Soliah-master
Diff
1diff --git a/themes/Soliah.zsh-theme b/themes/Soliah.zsh-theme
2index 7ad876d41756daf9911162235ac5a8a205a0656d..1c0ab3cc971e9633b7c42f32e118f0977d30375b 100644
3--- a/themes/Soliah.zsh-theme
4+++ b/themes/Soliah.zsh-theme
5@@ -1,6 +1,63 @@
6-PROMPT='%{$fg[blue]%}%B%20~%b%{$reset_color%}%{$(git_prompt_info)%} $ '
7+PROMPT='%{$fg[blue]%}%n%{$reset_color%} on %{$fg[red]%}%M%{$reset_color%} in %{$fg[blue]%}%~%b%{$reset_color%}$(git_time_since_commit)$(git_prompt_info)
8+$ '
910-ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg[green]%}"
11+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}"
12 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
13-ZSH_THEME_GIT_PROMPT_DIRTY="*%{$reset_color%}"
1415+# Text to display if the branch is dirty
16+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
17+
18+# Text to display if the branch is clean
19+ZSH_THEME_GIT_PROMPT_CLEAN=""
20+
21+# Colors vary depending on time lapsed.
22+ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
23+ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
24+ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
25+ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
26+
27+# Determine the time since last commit. If branch is clean,
28+# use a neutral color, otherwise colors will vary according to time.
29+function git_time_since_commit() {
30+ if git rev-parse --git-dir > /dev/null 2>&1; then
31+ # Only proceed if there is actually a commit.
32+ if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
33+ # Get the last commit.
34+ last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
35+ now=`date +%s`
36+ seconds_since_last_commit=$((now-last_commit))
37+
38+ # Totals
39+ MINUTES=$((seconds_since_last_commit / 60))
40+ HOURS=$((seconds_since_last_commit/3600))
41+
42+ # Sub-hours and sub-minutes
43+ DAYS=$((seconds_since_last_commit / 86400))
44+ SUB_HOURS=$((HOURS % 24))
45+ SUB_MINUTES=$((MINUTES % 60))
46+
47+ if [[ -n $(git status -s 2> /dev/null) ]]; then
48+ if [ "$MINUTES" -gt 30 ]; then
49+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
50+ elif [ "$MINUTES" -gt 10 ]; then
51+ COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
52+ else
53+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
54+ fi
55+ else
56+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
57+ fi
58+
59+ if [ "$HOURS" -gt 24 ]; then
60+ echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
61+ elif [ "$MINUTES" -gt 60 ]; then
62+ echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
63+ else
64+ echo "($COLOR${MINUTES}m%{$reset_color%}|"
65+ fi
66+ else
67+ COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
68+ echo "($COLOR~|"
69+ fi
70+ fi
71+}
72diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
73index c59ebaed48ebd8b7a3778c6d81f34126d101aa24..4643739ca51b136737c4a1981e3354b8162cb66c 100644
74--- a/tools/check_for_upgrade.sh
75+++ b/tools/check_for_upgrade.sh
76@@ -16,7 +16,7 @@ then
77 _update_zsh_update && return 0;
78 fi
7980- epoch_diff=$((${_current_epoch} - $LAST_EPOCH))
81+ epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
82 if [ $epoch_diff -gt 6 ]
83 then
84 echo "[Oh My Zsh] Would you like to check for updates?"