Browse code

Merge pull request #90 from steeef/steeef-theme

Steeef theme

Robby Russell authored on 26/05/2011 at 07:52:57
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,100 @@
0
+# prompt style and colors based on Steve Losh's Prose theme:
1
+# http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
2
+#
3
+# vcs_info modifications from Bart Trojanowski's zsh prompt:
4
+# http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
5
+#
6
+# git untracked files modification from Brian Carper:
7
+# http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
8
+
9
+function virtualenv_info {
10
+    [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
11
+}
12
+PR_GIT_UPDATE=1
13
+
14
+setopt prompt_subst
15
+autoload colors
16
+colors
17
+
18
+autoload -U add-zsh-hook
19
+autoload -Uz vcs_info
20
+
21
+#use extended color pallete if available
22
+if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
23
+    turquoise="%F{81}"
24
+    orange="%F{166}"
25
+    purple="%F{135}"
26
+    hotpink="%F{161}"
27
+    limegreen="%F{118}"
28
+else
29
+    turquoise="$fg[cyan]"
30
+    orange="$fg[yellow]"
31
+    purple="$fg[magenta]"
32
+    hotpink="$fg[red]"
33
+    limegreen="$fg[green]"
34
+fi
35
+
36
+# enable VCS systems you use
37
+zstyle ':vcs_info:*' enable git svn
38
+
39
+# check-for-changes can be really slow.
40
+# you should disable it, if you work with large repositories
41
+zstyle ':vcs_info:*:prompt:*' check-for-changes true
42
+
43
+# set formats
44
+# %b - branchname
45
+# %u - unstagedstr (see below)
46
+# %c - stagedstr (see below)
47
+# %a - action (e.g. rebase-i)
48
+# %R - repository path
49
+# %S - path in the repository
50
+PR_RST="%{${reset_color}%}"
51
+FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
52
+FMT_ACTION="(%{$limegreen%}%a${PR_RST})"
53
+FMT_UNSTAGED="%{$orange%}●"
54
+FMT_STAGED="%{$limegreen%}●"
55
+
56
+zstyle ':vcs_info:*:prompt:*' unstagedstr   "${FMT_UNSTAGED}"
57
+zstyle ':vcs_info:*:prompt:*' stagedstr     "${FMT_STAGED}"
58
+zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
59
+zstyle ':vcs_info:*:prompt:*' formats       "${FMT_BRANCH}"
60
+zstyle ':vcs_info:*:prompt:*' nvcsformats   ""
61
+
62
+
63
+function steeef_preexec {
64
+    case "$(history $HISTCMD)" in
65
+        *git*)
66
+            PR_GIT_UPDATE=1
67
+            ;;
68
+        *svn*)
69
+            PR_GIT_UPDATE=1
70
+            ;;
71
+    esac
72
+}
73
+add-zsh-hook preexec steeef_preexec
74
+
75
+function steeef_chpwd {
76
+    PR_GIT_UPDATE=1
77
+}
78
+add-zsh-hook chpwd steeef_chpwd
79
+
80
+function steeef_precmd {
81
+    if [[ -n "$PR_GIT_UPDATE" ]] ; then
82
+        # check for untracked files or updated submodules, since vcs_info doesn't
83
+        if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
84
+            PR_GIT_UPDATE=1
85
+            FMT_BRANCH="(%{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST})"
86
+        else
87
+            FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
88
+        fi
89
+        zstyle ':vcs_info:*:prompt:*' formats       "${FMT_BRANCH}"
90
+
91
+        vcs_info 'prompt'
92
+        PR_GIT_UPDATE=
93
+    fi
94
+}
95
+add-zsh-hook precmd steeef_precmd
96
+
97
+PROMPT=$'
98
+%{$purple%}%n%{$reset_color%} at %{$orange%}%m%{$reset_color%} in %{$limegreen%}%~%{$reset_color%} $vcs_info_msg_0_
99
+$(virtualenv_info)$ '