279cf279a67f274bc7ee1e4cb17231eff2694317

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #436 from smt/pull-request-1

Add ohmyzsh theme, my version of dogenpunk

Diff

 1diff --git a/themes/smt.zsh-theme b/themes/smt.zsh-theme
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..7a287523e551673ac8bea986a9f9122639aae6aa
 4--- /dev/null
 5+++ b/themes/smt.zsh-theme
 6@@ -0,0 +1,91 @@
 7+# -----------------------------------------------------------------------------
 8+#          FILE: smt.zsh-theme
 9+#   DESCRIPTION: oh-my-zsh theme file, based on dogenpunk by Matthew Nelson.
10+#        AUTHOR: Stephen Tudor (stephen@tudorstudio.com
11+#       VERSION: 0.1
12+#    SCREENSHOT: coming soon
13+# -----------------------------------------------------------------------------
14+
15+MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}"
16+local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%} "
17+
18+ZSH_THEME_GIT_PROMPT_PREFIX="|"
19+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
20+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}⚡%{$reset_color%}"
21+ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[red]%}!%{$reset_color%}"
22+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}"
23+
24+ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
25+ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
26+ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
27+ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
28+ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
29+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
30+
31+# Format for git_prompt_long_sha() and git_prompt_short_sha()
32+ZSH_THEME_GIT_PROMPT_SHA_BEFORE="➤ %{$fg_bold[yellow]%}"
33+ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}"
34+
35+function prompt_char() {
36+  git branch >/dev/null 2>/dev/null && echo "%{$fg[green]%}±%{$reset_color%}" && return
37+  hg root >/dev/null 2>/dev/null && echo "%{$fg_bold[red]%}☿%{$reset_color%}" && return
38+  echo "%{$fg[cyan]%}◯%{$reset_color%}"
39+}
40+
41+# Colors vary depending on time lapsed.
42+ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
43+ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
44+ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
45+ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
46+
47+# Determine the time since last commit. If branch is clean,
48+# use a neutral color, otherwise colors will vary according to time.
49+function git_time_since_commit() {
50+    if git rev-parse --git-dir > /dev/null 2>&1; then
51+        # Only proceed if there is actually a commit.
52+        if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
53+            # Get the last commit.
54+            last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
55+            now=`date +%s`
56+            seconds_since_last_commit=$((now-last_commit))
57+
58+            # Totals
59+            MINUTES=$((seconds_since_last_commit / 60))
60+            HOURS=$((seconds_since_last_commit/3600))
61+
62+            # Sub-hours and sub-minutes
63+            DAYS=$((seconds_since_last_commit / 86400))
64+            SUB_HOURS=$((HOURS % 24))
65+            SUB_MINUTES=$((MINUTES % 60))
66+
67+            if [[ -n $(git status -s 2> /dev/null) ]]; then
68+                if [ "$MINUTES" -gt 30 ]; then
69+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
70+                elif [ "$MINUTES" -gt 10 ]; then
71+                    COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
72+                else
73+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
74+                fi
75+            else
76+                COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
77+            fi
78+
79+            if [ "$HOURS" -gt 24 ]; then
80+                echo "[$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}]"
81+            elif [ "$MINUTES" -gt 60 ]; then
82+                echo "[$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}]"
83+            else
84+                echo "[$COLOR${MINUTES}m%{$reset_color%}]"
85+            fi
86+        else
87+            COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
88+            echo "[$COLOR~]"
89+        fi
90+    fi
91+}
92+
93+PROMPT='
94+%{$fg[blue]%}%m%{$reset_color%} 福 %{$fg[cyan]%}%~ %{$reset_color%}$(git_prompt_short_sha)$(git_prompt_info)
95+%{$fg[red]%}%!%{$reset_color%} $(prompt_char) : '
96+
97+RPROMPT='${return_status}$(git_time_since_commit)$(git_prompt_status)%{$reset_color%}'