Browse code

Merged pull request #288 from dogenpunk/dogenpunk_theme.

Adding dogenpunk theme

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