-
Notifications
You must be signed in to change notification settings - Fork 2
/
staples.zsh-theme
190 lines (158 loc) · 4.64 KB
/
staples.zsh-theme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# oh-my-zsh Bureau Theme
# Wildly hacked on to add context sensitive tags on right side
### NVM
ZSH_THEME_NVM_PROMPT_PREFIX="%B⬡%b "
ZSH_THEME_NVM_PROMPT_SUFFIX=""
### Git [±master ▾●]
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg_bold[green]%}%{$reset_color%}%{$fg_bold[white]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[blue]%}✓%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[red]%}▴%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[green]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[cyan]%}●%{$reset_color%}"
bureau_git_branch () {
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
echo "${ref#refs/heads/}"
}
bureau_git_status () {
_INDEX=$(command git status -uno --porcelain -b 2> /dev/null)
_STATUS=""
if $(echo "$_INDEX" | grep '^[AMRD]. ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
fi
if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
fi
if $(echo "$_INDEX" | grep '^## .*ahead' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
if $(echo "$_INDEX" | grep '^## .*behind' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
if $(echo "$_INDEX" | grep '^## .*diverged' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
echo $_STATUS
}
bureau_git_prompt () {
local _branch=$(bureau_git_branch)
local _branch=$(bureau_git_branch)
# if [ -n "$SSH_CLIENT" ]; then
# _status=""
# else
local _status=$(bureau_git_status)
# fi
local _result=""
if [[ "${_branch}x" != "x" ]]; then
_result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch"
if [[ "${_status}x" != "x" ]]; then
_result="$_result $_status"
fi
_result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
echo $_result
}
_PATH="%{$fg_bold[white]%}%~%{$reset_color%}"
if [[ $EUID -eq 0 ]]; then
_USERNAME="%{$fg_bold[red]%}%n"
_LIBERTY="%{$fg[red]%}#"
else
_USERNAME="%{$fg_bold[white]%}%n"
_LIBERTY="%{$fg[green]%}$"
fi
_USERNAME="$_USERNAME%{$reset_color%}@%m"
_LIBERTY="$_LIBERTY%{$reset_color%}"
get_space () {
local STR=$1$2
local zero='%([BSUbfksu]|([FB]|){*})'
local LENGTH=${#${(S%%)STR//$~zero/}}
local SPACES=""
(( LENGTH = ${COLUMNS} - $LENGTH - 1))
for i in {0..$LENGTH}
do
SPACES="$SPACES "
done
echo $SPACES
}
get_usables () {
local usables='';
if [[ -a gulpfile.js ]]; then
usables="<gulp> $usables"
fi
if [[ -a 'composer.json' ]]; then
usables="<composer> $usables"
fi
if [[ -f 'package.json' ]]; then
usables="<npm> $usables"
fi
if [[ -f 'VagrantFile' ]]; then
usables="<vagrant> $usables"
fi
if [[ -f 'Gemfile' ]]; then
usables="<bundler> $usables"
fi
if [[ -n $usables ]]; then
echo "%{$fg[magenta]%}$usables%{$reset_color%}"
fi
}
setopt prompt_subst
#_1LEFT="$_USERNAME $_PATH"
_1RIGHT=' [%*] '
_1LEFT="$_PATH"
bureau_precmd () {
_1SPACES=`get_space $_1LEFT $_1RIGHT`
print
print -rP "$_1LEFT$_1SPACES$_1RIGHT"
}
ssh_status_prompt () {
if [[ -n "$SSH_CLIENT" ]]; then
echo '%n@%m '
fi
}
# Show colorful chevrons according to what month it is.
seasonal_chevrons () {
local date=$(date)
local chevrons="❯❯❯"
case $date in
# spring
*Mar*|*Apr*|*May*)
chevrons="%F{#81D4FA}❯%F{#A5D6A7}❯%F{#FFF59D}❯%f"
;;
# summer
*Jun*|*Jul*|*Aug*)
chevrons="%F{#A5D6A7}❯%F{#FFF59D}❯%F{#FFAB91}❯%f"
;;
# fall
*Sep*|*Oct*|*Nov*)
chevrons="%F{#E6EE9C}❯%F{#FFCC80}❯%F{#F48FB1}❯%f"
;;
# winter
*Dec*|*Jan*|*Feb*)
chevrons="%F{#B39DDB}❯%F{#81D4FA}❯%F{#A5D6A7}❯%f"
;;
*)
;;
esac
echo -en $chevrons
}
last_status () {
echo "%(?:%{$fg_bold[green]%}$(seasonal_chevrons):%{$fg_bold[red]%}$(seasonal_chevrons))"
}
#setopt prompt_subst
PROMPT='%{$fg[red]%}$(ssh_status_prompt)$(last_status)%{$reset_color%}$_LIBERTY '
#RPROMPT='$(nvm_prompt_info) $(get_usables) $(bureau_git_prompt)'
RPROMPT='$(get_usables)$(bureau_git_prompt)'
autoload -U add-zsh-hook
add-zsh-hook precmd bureau_precmd