-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsobole.zsh-theme
236 lines (195 loc) · 7.59 KB
/
sobole.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#
# Sobole ZSH Theme
#
# Author: Nikita Sobolev, github.com/sobolevn
# License: WTFPL
# https://github.com/sobolevn/sobole-zsh-theme
# Testing colors:
#
# for i in {0..255} ; do
# printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
# if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
# printf "\n";
# fi
# done
# ----------------------------------------------------------------------------
# PROMPT settings
# These settings changes how your terminal prompt looks like
# ----------------------------------------------------------------------------
PROMPT='$(__sobole::current_venv)$(__sobole::user_info)$(__sobole::current_dir) $(git_prompt_info)
$(__sobole::current_caret) '
PROMPT2='. '
_return_status="%(?..%{$fg[red]%}%? ⚠️%{$reset_color%})"
RPROMPT='%{$(echotc UP 1)%} ${_return_status}%{$(echotc DO 1)%}'
__sobole::current_caret () {
# This function sets caret color and sign
# based on theme and privileges.
if [[ "$USER" == 'root' ]] || [[ "$(id -u "$USER")" == 0 ]]; then
CARET_COLOR='red'
CARET_SIGN='#'
else
CARET_SIGN='»'
if [[ "$SOBOLE_THEME_MODE" == 'dark' ]]; then
CARET_COLOR='white'
else
CARET_COLOR='black'
fi
fi
echo "%{$fg[$CARET_COLOR]%}$CARET_SIGN%{$reset_color%}"
}
__sobole::current_dir () {
# Settings up current directory and settings max width for it:
local max_pwd_length="${SOBOLE_MAX_DIR_LEN:-65}"
local color
if [[ "$SOBOLE_THEME_MODE" == 'dark' ]]; then
color='white'
else
color='blue'
fi
if [[ $(echo -n "$PWD" | wc -c) -gt "$max_pwd_length" ]]; then
echo "%{$fg_bold[$color]%}%-1~ ... %2~%{$reset_color%} "
else
echo "%{$fg_bold[$color]%}%~%{$reset_color%} "
fi
}
__sobole::user_info () {
# Shows user in the PROMPT if needed.
if [[ ! -z "$SOBOLE_DEFAULT_USER" ]] &&
[[ "$USER" != "$SOBOLE_DEFAULT_USER" ]]; then
# This only works if `$SOBOLE_DEFAULT_USER` is not empty.
# So, when you log in as other user, using `su` for example,
# your shell tells you who you are. Otherwise it stays silent.
# You should set `$SOBOLE_DEFAULT_USER` somewhere in your `.zshrc`:
echo "@$USER "
fi
}
# ----------------------------------------------------------------------------
# virtualenv settings
# These settings changes how virtualenv is displayed.
# ----------------------------------------------------------------------------
# Disable the standard prompt:
export VIRTUAL_ENV_DISABLE_PROMPT=1
__sobole::current_venv () {
if [[ ! -z "$VIRTUAL_ENV" ]]; then
# Show this info only if virtualenv is activated:
local dir=$(basename "$VIRTUAL_ENV")
echo "($dir) "
fi
}
# ----------------------------------------------------------------------------
# VCS specific colors and icons
# These settings defines how icons and text is displayed for
# vcs-related stuff. We support only `git`.
# ----------------------------------------------------------------------------
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚%{$reset_color%}"
# ----------------------------------------------------------------------------
# `ls` colors
# Made with: http://geoff.greer.fm/lscolors/
# ----------------------------------------------------------------------------
if [[ "$SOBOLE_THEME_MODE" == 'dark' ]]; then
export LSCOLORS='gxfxcxdxbxegedabagacad'
export LS_COLORS='di=36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43'
else
export LSCOLORS='exfxcxdxBxegedabagacab'
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=1;31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;41'
fi
# Turns on colors with default unix `ls` command:
export CLICOLOR=1
# ----------------------------------------------------------------------------
# `grep` colors and options
# ----------------------------------------------------------------------------
export GREP_COLOR='1;35'
# ----------------------------------------------------------------------------
# `zstyle` colors
# Internal zsh styles: completions, suggestions, etc
# ----------------------------------------------------------------------------
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# set descriptions format to enable group support
zstyle ':completion:*:descriptions' format '[%d]'
# ----------------------------------------------------------------------------
# zsh-syntax-highlighting tweaks
# This setting works only unless `$SOBOLE_DONOTTOUCH_HIGHLIGHTING`
# is set. Any value is fine. For exmaple, you can set it to `true`.
# Anyway, it will only take effect if `zsh-syntax-highlighting`
# is installed, otherwise it does nothing.
# ----------------------------------------------------------------------------
if [[ "$SOBOLE_SYNTAX_HIGHLIGHTING" != 'false' ]]; then
typeset -A ZSH_HIGHLIGHT_STYLES
# Disable strings highlighting:
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='none'
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='none'
if [[ "$SOBOLE_THEME_MODE" == 'dark' ]]; then
ZSH_HIGHLIGHT_STYLES[path]='fg=white,underline'
fi
if [[ "$SOBOLE_THEME_MODE" == 'dark' ]]; then
export SOBOLE_SYNTAX_THEME=Dracula
else
export SOBOLE_SYNTAX_THEME=GitHub
fi
fi
# ----------------------------------------------------------------------------
# fzf and fzf-tab tweaks.
# See:
# - https://github.com/junegunn/fzf
# - https://github.com/Aloxaf/fzf-tab
# ----------------------------------------------------------------------------
if [[ "$SOBOLE_FZF_THEME" != 'false' ]]; then
if (( $+commands[fzf] )); then
# This theme is the same for both light and dark themes:
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS
--color=bg:-1,fg:-1,bg+:#dce7f2,fg+:bright-black
--color=hl:bright-blue,hl+:blue
--color=header:green,info:green,pointer:blue
--color=marker:bright-blue,prompt:black,spinner:blue"
# fzf-tab theme, setting the default color for suggestions (blue for me)
# Test all colors: `msgcat --color=test`
zstyle ':fzf-tab:*' default-color $'\x1b[30m'
# Matched text highlight
local fzf_flags
fzf_flags=( '--color=hl:bright-blue' )
zstyle ':fzf-tab:*' fzf-flags $fzf_flags
fi
fi
# ----------------------------------------------------------------------------
# less (and man) colors
# ----------------------------------------------------------------------------
if [[ "$SOBOLE_LESS_THEME" != 'false' ]]; then
if [[ "$SOBOLE_THEME_MODE" == 'dark' ]]; then
export LESS_TERMCAP_mb="$(printf '\e[1;35m')"
export LESS_TERMCAP_md="$(printf '\e[1;35m')"
else
export LESS_TERMCAP_mb="$(printf '\e[1;34m')"
export LESS_TERMCAP_md="$(printf '\e[1;34m')"
fi
export LESS_TERMCAP_me="$(printf '\e[0m')"
export LESS_TERMCAP_se=$(printf '\e[0m')
export LESS_TERMCAP_so=$(printf '\e[30m')
export LESS_TERMCAP_ue=$(printf '\e[0m')
export LESS_TERMCAP_us=$(printf '\e[1;32m')
fi
# ----------------------------------------------------------------------------
# zsh hooks
# ----------------------------------------------------------------------------
_SOBOLE_ADD_LINE_SEPARATOR='false'
__sobole::preexec () {
if [[ $# -eq 0 ]] || [[ "$2" == 'clear' ]]; then
_SOBOLE_ADD_LINE_SEPARATOR='false'
else
_SOBOLE_ADD_LINE_SEPARATOR='true'
fi
}
__sobole::precmd () {
local cmd_result="$?"
if [[ "$_SOBOLE_ADD_LINE_SEPARATOR" == 'true' ]] ||
[[ "$cmd_result" -ne 0 ]]; then
print
fi
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec __sobole::preexec
add-zsh-hook precmd __sobole::precmd