Diff
1diff --git a/themes/Soliah.zsh-theme b/themes/Soliah.zsh-theme
2index 1c0ab3cc971e9633b7c42f32e118f0977d30375b..237e70fda314cc6ac047ebfbde7c38b2c641f8c3 100644
3--- a/themes/Soliah.zsh-theme
4+++ b/themes/Soliah.zsh-theme
5@@ -1,4 +1,4 @@
6-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)
7+PROMPT='%{$fg[blue]%}%n%{$reset_color%} on %{$fg[red]%}%M%{$reset_color%} in %{$fg[blue]%}%~%b%{$reset_color%}$(git_time_since_commit)$(check_git_prompt_info)
8 $ '
9
10 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}"
11@@ -16,6 +16,29 @@ ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
12 ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
13 ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
14
15+
16+# Git sometimes goes into a detached head state. git_prompt_info doesn't
17+# return anything in this case. So wrap it in another function and check
18+# for an empty string.
19+function check_git_prompt_info() {
20+ if git rev-parse --git-dir > /dev/null 2>&1; then
21+ if [[ -z $(git_prompt_info) ]]; then
22+ echo "%{$fg[magenta]%}detached-head%{$reset_color%})"
23+ else
24+ echo "$(git_prompt_info)"
25+ fi
26+ fi
27+}
28+
29+# Determine if we are using a gemset.
30+function rvm_gemset() {
31+ GEMSET=`rvm gemset list | grep '=>' | cut -b4-`
32+ if [[ -n $GEMSET ]]; then
33+ echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|"
34+ fi
35+
36+}
37+
38 # Determine the time since last commit. If branch is clean,
39 # use a neutral color, otherwise colors will vary according to time.
40 function git_time_since_commit() {
41@@ -49,15 +72,15 @@ function git_time_since_commit() {
42 fi
43
44 if [ "$HOURS" -gt 24 ]; then
45- echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
46+ echo "($(rvm_gemset)$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
47 elif [ "$MINUTES" -gt 60 ]; then
48- echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
49+ echo "($(rvm_gemset)$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
50 else
51- echo "($COLOR${MINUTES}m%{$reset_color%}|"
52+ echo "($(rvm_gemset)$COLOR${MINUTES}m%{$reset_color%}|"
53 fi
54 else
55 COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
56- echo "($COLOR~|"
57+ echo "($(rvm_gemset)$COLOR~|"
58 fi
59 fi
60 }