-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfunkyberlin.zsh-theme
More file actions
131 lines (105 loc) · 3.63 KB
/
funkyberlin.zsh-theme
File metadata and controls
131 lines (105 loc) · 3.63 KB
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
# Shout out to the makers of the bureau theme - This is heavily inspired by them.
# (https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/bureau.zsh-theme)
ZSH_THEME_NVM_PROMPT_PREFIX="%B⬡%b "
ZSH_THEME_NVM_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_PREFIX="[git%{$reset_color%}%{$FG[176]%} "
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$FG[154]%}✓%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{$FG[154]%}▴%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_BEHIND="%{$FG[196]%}▾%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$FG[154]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$FG[202]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
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/}"
}
git_status() {
_STATUS=""
# check status of files
_INDEX=$(command git status --porcelain 2> /dev/null)
if [[ -n "$_INDEX" ]]; then
if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
fi
if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
if $(echo "$_INDEX" | command grep -q '^UU '); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
else
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
# check status of local repository
_INDEX=$(command git status --porcelain -b 2> /dev/null)
if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
if $(echo "$_INDEX" | command grep -q '^## .*behind'); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
if $(command git rev-parse --verify refs/stash &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
fi
echo $_STATUS
}
git_prompt () {
local _branch=$(git_branch)
local _status=$(git_status)
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
}
svn_prompt () {
local _rev
local _branch
local _result=""
local _SVN_PREFIX="svn"
if in_svn; then
_rev=$(svn_get_rev_nr)
_branch=$(svn_get_branch_name)
_repo=$(svn_get_repo_name)
_modified=$(svn st | grep "M" | wc -l | tr -d '[:space:]')
_untracked=$(svn st | grep "?" | wc -l | tr -d '[:space:]')
if [ `svn_dirty_choose_pwd 1 0` -eq 1 ]; then
_result="[$_SVN_PREFIX $fg_bold[red]±$reset_color M:$fg[red]$_modified$reset_color ?:$fg[yellow]$_untracked$reset_color]"
else
_result="[$_SVN_PREFIX $FG[154]✓$reset_color]"
fi
fi
echo $_result
}
_PATH="$fg[yellow]%~$reset_color"
if [[ $EUID -eq 0 ]]; then
_USERNAME="%{$fg_bold[red]%}%n"
_LIBERTY="%{$fg[red]%}#"
else
_USERNAME="%{$fg_bold[blue]%}%n"
_LIBERTY="%{$fg[green]%}$"
fi
_USERNAME="$_USERNAME%{$reset_color%}@%m"
_LIBERTY="$_LIBERTY%{$reset_color%}"
_TOP="$_USERNAME $_PATH"
_BOTTOM="%* > $_LIBERTY "
berlin_precmd () {
print
_VERSIONCTRL="$(git_prompt)$(svn_prompt)$(nvm_prompt_info)"
print -P "$_TOP $_VERSIONCTRL"
}
PROMPT="$_BOTTOM"
autoload -U add-zsh-hook
add-zsh-hook precmd berlin_precmd