-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsyoo5b.zsh-theme
153 lines (119 loc) · 4.74 KB
/
jsyoo5b.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
#!/bin/zsh
# oh-my-zsh JSYoo5B theme
###############################################################################
# Customize
## Change this associative array to modify theme in runtime
declare -A ZSH_THEME_CONF
## Visual effects for each parts
ZSH_THEME_CONF[TIME_EFFECT]="%F{green}" # Time: Green text
ZSH_THEME_CONF[PWD_EFFECT]="%F{blue}%B" # PWD: Blue text, Bolded
ZSH_THEME_CONF[USER_EFFECT]="%F{magenta}" # Username: Magenta text
ZSH_THEME_CONF[HOST_EFFECT]="%F{yellow}" # Hostname: Yellow text
ZSH_THEME_CONF[PROMPT_ROOT_EFFECT]="%F{red}" # Root user: Red text
ZSH_THEME_CONF[PROMPT_GENERAL_EFFECT]="%F{cyan}" # General users: Cyan text
## Texts for customizing theme in runtime
## (Add your visual effects inside each variable)
## (Visual effects will be reset after showing each variable)
ZSH_THEME_CONF[USER_PREFIX]='' # Default: blank
ZSH_THEME_CONF[USER_SUFFIX]='' # Default: blank
ZSH_THEME_CONF[HOST_PREFIX]='' # Default: blank
ZSH_THEME_CONF[HOST_SUFFIX]='' # Default: blank
ZSH_THEME_CONF[SHELL_NAME]="zsh" # Default: "zsh"
ZSH_THEME_CONF[RPROMPT_PREFIX]='' # Default: blank
ZSH_THEME_CONF[RPROMPT_SUFFIX]='' # Default: blank
###############################################################################\
# configure modules for zsh
setopt PROMPT_SUBST
autoload colors
colors
# Define constants
_CLR="%f%k%b%u" # Reset all visual effects
###############################################################################
# Main prompt (first line)
## Show current time (hour, minute, second)
_theme_func_timestamp() {
local time_str="%D{%H:%M:%S}" # HH:MM:SS
echo "\${ZSH_THEME_CONF[TIME_EFFECT]}${time_str}${_CLR}"
}
## Show pwd in absolute path format
## When the path expects line wrap, it will truncate to fit console width
_theme_func_pwd() {
local width="\$(( \${COLUMNS:-80} - 10 ))" # 10 == "┌HH:MM:SS "
local pwd_str="%${width}<...<%/%<<" # ...h-my-zsh/custom/themes
echo "\${ZSH_THEME_CONF[PWD_EFFECT]}${pwd_str}${_CLR}"
}
###############################################################################
###############################################################################
# Main prompt (second line)
## Show username_at_hostname
_theme_func_user_at_host() {
local user host
user="\${ZSH_THEME_CONF[USER_PREFIX]}${_CLR}"
user="${user}\${ZSH_THEME_CONF[USER_EFFECT]}%n${_CLR}"
user="${user}\${ZSH_THEME_CONF[USER_SUFFIX]}${_CLR}"
host="\${ZSH_THEME_CONF[HOST_PREFIX]}${_CLR}"
host="${host}\${ZSH_THEME_CONF[HOST_EFFECT]}%m${_CLR}"
host="${host}\${ZSH_THEME_CONF[HOST_SUFFIX]}${_CLR}"
echo "${user}@${host}"
}
## Show current shell name and prompt character
_theme_func_shell_and_prompt() {
local shell_name
local prompt eff
local last_status
shell_name="\${ZSH_THEME_CONF[SHELL_NAME]}${_CLR}"
if [ $UID -eq 0 ]; then
prompt="#"
eff="\${ZSH_THEME_CONF[PROMPT_ROOT_EFFECT]}"
else
prompt="$"
eff="\${ZSH_THEME_CONF[PROMPT_GENERAL_EFFECT]}"
fi
last="%(?,,%F{red}<%?>)"
echo "${shell_name}${last}${_CLR}${eff}${prompt}${_CLR}"
}
###############################################################################
# Evaluate PROMPT (ZSH_THEME_CONF & runtime vars are not evaluated)
PROMPT="
┌$(_theme_func_timestamp) $(_theme_func_pwd)
└$(_theme_func_user_at_host):$(_theme_func_shell_and_prompt) "
###############################################################################
# Sub prompt (right of main prompt second line)
## Show right prompt prefix
_theme_func_rpr_pre() {
echo "\${ZSH_THEME_CONF[RPROMPT_PREFIX]}${_CLR}"
}
## Show right prompt suffix
_theme_func_rpr_suf() {
echo "\${ZSH_THEME_CONF[RPROMPT_SUFFIX]}${_CLR}"
}
git_prompt_detail() {
local info
local stat_mark
info="$(git_prompt_info)"
if [[ $info != "" ]]; then
stat_mark="$(parse_git_dirty)"
fi
if [[ $stat_mark = $ZSH_THEME_GIT_PROMPT_DIRTY ]]; then
stat_mark="${_CLR}($(git_prompt_status)${_CLR})"
else
stat_mark=""
fi
echo "${info}${stat_mark}"
}
## Right prompt shows git information as default
ZSH_THEME_GIT_PROMPT_PREFIX="%F{green}"
ZSH_THEME_GIT_PROMPT_SUFFIX="${_CLR}"
ZSH_THEME_GIT_PROMPT_DIRTY="${_CLR} "
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_UNKNOWN="%F{yellow}?"
ZSH_THEME_GIT_PROMPT_ADDED="%F{cyan}+${_CLR}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%F{yellow}*${_CLR}"
ZSH_THEME_GIT_PROMPT_DELETED="%F{red}-${_CLR}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%F{magenta}?${_CLR}"
###############################################################################
# Evaluate RPROMPT (Ext. func. call & ZSH_THEME_CONT are not evaluated)
RPROMPT="$(_theme_func_rpr_pre)\$(git_prompt_detail)$(_theme_func_rpr_suf)"
# Unset internal variables and functions
unset _CLR
unset -f -m "_theme_func_*"