-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdaily.zsh-theme
120 lines (96 loc) · 2.72 KB
/
daily.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
#!/bin/zsh
setopt prompt_subst
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE BLACK; do
eval PR_$color='%{$fg[${(L)color}]%}'
eval PR_BOLD_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
done
TERMWIDTH=${COLUMNS}
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY=" $PR_RED*$PR_NO_COLOUR"
function _theme_line() {
if [ $? -eq 0 ]; then
echo "%{$PR_BOLD_BLACK%}${(l:$COLUMNS::-:)}%{$PR_NO_COLOUR%}"
else
echo "%{$PR_RED$?%-}${(l:$COLUMNS - $#?::-:)}%{$PR_NO_COLOUR%}"
fi
}
function _theme_git_info() {
if [ -z "$(git_prompt_info)" ]; then
echo ""
elif [ -z "$(git_prompt_short_sha)" ]; then
echo " [$(git_prompt_info) root]"
else
echo " [$(git_prompt_info) $(git_prompt_short_sha)]"
fi
}
function _theme_ssh() {
if [ "$SSH_CLIENT" != "" ]; then
echo "${PR_BOLD_BLUE}(SSH!)${PR_NO_COLOUR} "
fi
}
function _theme_proxy() {
if ! [[ -z "$HTTP_PROXY" && -z "$HTTPS_PROXY" && -z "$ALL_PROXY" ]]; then
echo "${PR_BOLD_RED}(PROXY)${PR_NO_COLOUR} "
fi
}
function _theme_jobs() {
echo "%(1j.${PR_BOLD_RED}jobs:%j${PR_NO_COLOUR} .)"
}
_theme-zle-line-init() {
[[ $CONTEXT == start ]] || return 0
# Start regular line editor
(( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[1]
zle .recursive-edit
local -i ret=$?
(( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2]
# If we received EOT, we exit the shell
if [[ $ret == 0 && $KEYS == $'\4' && $(jobs | wc -l) -eq 0 ]]; then
_theme_prompt_compact=1
zle .reset-prompt
exit
fi
# Line edition is over. Shorten the current prompt.
_theme_prompt_compact=1
if [[ -z "${BUFFER// }" ]]; then
_theme_prompt_compact=2
else
_theme_prompt_compact=1
_theme_prompt_br=1
fi
zle .reset-prompt
unset _theme_prompt_compact
if (( ret )); then
# Ctrl-C
zle .send-break
else
# Enter
zle .accept-line
fi
return ret
}
zle -N zle-line-init _theme-zle-line-init
function _theme_prompt() {
case "${_theme_prompt_compact}" in
1)
echo " ${PR_MAGENTA}\$${PR_NO_COLOUR} "
;;
2)
echo ""
;;
*)
if (( $_theme_prompt_br )); then
echo ""
fi
echo "%(!.${PR_RED}.${PR_BLUE})$PR_NO_COLOUR %(!.${PR_RED}root$PR_NO_COLOUR.${PR_BOLD_BLUE}%n$PR_NO_COLOUR) $(_theme_ssh)$(_theme_proxy)$(_theme_jobs)%3~$(_theme_git_info)${PR_NO_COLOUR}
%(?. .$PR_RED ! $PR_NO_COLOUR)%(!.${PR_RED}#${PR_NOCOLOR}.${PR_BLUE}>$PR_NO_COLOUR) ${PR_NO_COLOUR}"
;;
esac
}
# PROMPT='$(_theme_line) ...'
PROMPT='$(_theme_prompt)'