1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,98 @@ |
0 |
+#------------------------------------------------------------------------------- |
|
1 |
+# Guru theme for oh-my-zsh by Adam Lindberg |
|
2 |
+# (Needs Git plugin for current_branch method) |
|
3 |
+#------------------------------------------------------------------------------- |
|
4 |
+ |
|
5 |
+ |
|
6 |
+# Color shortcuts |
|
7 |
+R=$fg[red] |
|
8 |
+Y=$fg[yellow] |
|
9 |
+G=$fg[green] |
|
10 |
+M=$fg[magenta] |
|
11 |
+W=$fg[white] |
|
12 |
+B=$fg[black] |
|
13 |
+RB=$fg_bold[red] |
|
14 |
+YB=$fg_bold[yellow] |
|
15 |
+GB=$fg_bold[green] |
|
16 |
+MB=$fg_bold[magenta] |
|
17 |
+WB=$fg_bold[white] |
|
18 |
+BB=$fg_bold[black] |
|
19 |
+RESET=$reset_color |
|
20 |
+ |
|
21 |
+if [ "$(whoami)" = "root" ]; then |
|
22 |
+ PROMPTCOLOR="%{$RB%}" PREFIX="-!-"; |
|
23 |
+else |
|
24 |
+ PROMPTCOLOR="%{$BB%}" PREFIX="---"; |
|
25 |
+fi |
|
26 |
+ |
|
27 |
+local return_code="%(?..%{$R%}%? ↵%{$RESET%})" |
|
28 |
+ |
|
29 |
+GIT_PREFIX="%{$YB%}‹" |
|
30 |
+GIT_SUFFIX="%{$YB%}›" |
|
31 |
+ |
|
32 |
+# Get the status of the working tree (copied and modified from git.zsh) |
|
33 |
+custom_git_prompt_status() { |
|
34 |
+ INDEX=$(git status --porcelain 2> /dev/null) |
|
35 |
+ STATUS="" |
|
36 |
+ # Non-staged |
|
37 |
+ if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then |
|
38 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" |
|
39 |
+ fi |
|
40 |
+ if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then |
|
41 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" |
|
42 |
+ fi |
|
43 |
+ if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then |
|
44 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" |
|
45 |
+ fi |
|
46 |
+ if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then |
|
47 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" |
|
48 |
+ elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then |
|
49 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" |
|
50 |
+ elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then |
|
51 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" |
|
52 |
+ fi |
|
53 |
+ # Staged |
|
54 |
+ if $(echo "$INDEX" | grep '^D ' &> /dev/null); then |
|
55 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS" |
|
56 |
+ fi |
|
57 |
+ if $(echo "$INDEX" | grep '^R ' &> /dev/null); then |
|
58 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS" |
|
59 |
+ fi |
|
60 |
+ if $(echo "$INDEX" | grep '^M ' &> /dev/null); then |
|
61 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS" |
|
62 |
+ fi |
|
63 |
+ if $(echo "$INDEX" | grep '^A' &> /dev/null); then |
|
64 |
+ STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS" |
|
65 |
+ fi |
|
66 |
+ echo $STATUS |
|
67 |
+} |
|
68 |
+ |
|
69 |
+# get the name of the branch we are on (copied and modified from git.zsh) |
|
70 |
+function custom_git_prompt() { |
|
71 |
+ ref=$(git symbolic-ref HEAD 2> /dev/null) || return |
|
72 |
+ echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_ahead)$(parse_git_dirty)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX" |
|
73 |
+} |
|
74 |
+ |
|
75 |
+PROMPT='${PROMPTCOLOR}$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' |
|
76 |
+RPS1="${return_code}" |
|
77 |
+ |
|
78 |
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$YB%}‹" |
|
79 |
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$YB%}›%{$RESET%} " |
|
80 |
+ |
|
81 |
+ZSH_THEME_GIT_PROMPT_AHEAD="%{$BB%}➝" |
|
82 |
+ |
|
83 |
+# Staged |
|
84 |
+ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A" |
|
85 |
+ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED="%{$G%}M" |
|
86 |
+ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R" |
|
87 |
+ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D" |
|
88 |
+ |
|
89 |
+# Not-staged |
|
90 |
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}??" |
|
91 |
+ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M" |
|
92 |
+ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D" |
|
93 |
+ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU" |
|
94 |
+ |
|
95 |
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}* " |
|
96 |
+ |
|
97 |
+ZSH_THEME_GIT_PROMPT_CLEAN="" |