forked from jeremyFreeAgent/oh-my-zsh-powerline-theme
-
Notifications
You must be signed in to change notification settings - Fork 11
/
solarized-powerline.zsh-theme
163 lines (145 loc) · 4.61 KB
/
solarized-powerline.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
# You can set following options in your .zshrc
# OS detection
[[ -n "${OS}" ]] || OS=$(uname)
# background color
BG_COLOR_BASE03=%K{8}
BG_COLOR_BASE02=%K{0}
BG_COLOR_BASE01=%K{10}
BG_COLOR_BASE00=%K{11}
BG_COLOR_BASE0=%K{12}
BG_COLOR_BASE1=%K{14}
BG_COLOR_BASE2=%K{7}
BG_COLOR_BASE3=%K{15}
BG_COLOR_YELLOW=%K{3}
BG_COLOR_ORANGE=%K{1}
BG_COLOR_RED=%K{9}
BG_COLOR_MAGENTA=%K{5}
BG_COLOR_VIOLET=%K{13}
BG_COLOR_BLUE=%K{4}
BG_COLOR_CYAN=%K{6}
BG_COLOR_GREEN=%K{2}
# foreground color
FG_COLOR_BASE03=%F{8}
FG_COLOR_BASE02=%F{0}
FG_COLOR_BASE01=%F{10}
FG_COLOR_BASE00=%F{11}
FG_COLOR_BASE0=%F{12}
FG_COLOR_BASE1=%F{14}
FG_COLOR_BASE2=%F{7}
FG_COLOR_BASE3=%F{15}
FG_COLOR_YELLOW=%F{3}
FG_COLOR_ORANGE=%F{1}
FG_COLOR_RED=%F{9}
FG_COLOR_MAGENTA=%F{5}
FG_COLOR_VIOLET=%F{13}
FG_COLOR_BLUE=%F{4}
FG_COLOR_CYAN=%F{6}
FG_COLOR_GREEN=%F{2}
# reset color
local RESET_COLOR=%f%k%b
local RESET=%{$RESET_COLOR%}
local RETURN_CODE="%(?..$FG_COLOR_RED%? ↵$RESET)"
local ARROW_SYMBOL=''
local ZSH_TIME=%D{%H:%M}
local PADDING=''
if [ $OS = "Darwin" ]; then
local LOGO=""
else
local LOGO="🐧"
fi
GIT_DIRTY_COLOR=%F{196}
GIT_CLEAN_COLOR=%F{118}
GIT_PROMPT_INFO=%F{012}
ZSH_THEME_GIT_PROMPT_PREFIX=" "
ZSH_THEME_GIT_PROMPT_SUFFIX="$GIT_PROMPT_INFO"
ZSH_THEME_GIT_PROMPT_DIRTY=" $GIT_DIRTY_COLOR✘"
ZSH_THEME_GIT_PROMPT_CLEAN=" $GIT_CLEAN_COLOR✔"
ZSH_THEME_GIT_PROMPT_ADDED="%F{082}✚%f"
ZSH_THEME_GIT_PROMPT_MODIFIED="%F{166}✹%f"
ZSH_THEME_GIT_PROMPT_DELETED="%F{160}✖%f"
ZSH_THEME_GIT_PROMPT_RENAMED="%F{220]➜%f"
ZSH_THEME_GIT_PROMPT_UNMERGED="%F{082]═%f"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%F{190]✭%f"
# option defaults
[[ -n "$ZSH_POWERLINE_SHOW_USER" ]] || ZSH_POWERLINE_SHOW_USER=true
[[ -n "$ZSH_POWERLINE_SHOW_IP" ]] || ZSH_POWERLINE_SHOW_IP=true
[[ -n "$ZSH_POWERLINE_SHOW_OS" ]] || ZSH_POWERLINE_SHOW_OS=true
[[ -n "$ZSH_POWERLINE_SHOW_TIME" ]] || ZSH_POWERLINE_SHOW_TIME=true
[[ -n "$ZSH_POWERLINE_SINGLE_LINE" ]] || ZSH_POWERLINE_SINGLE_LINE=false
[[ -n "$ZSH_POWERLINE_SHOW_GIT_STATUS" ]] || ZSH_POWERLINE_SHOW_GIT_STATUS=true
[[ -n "$ZSH_POWERLINE_SHOW_GIT_BRANCH_ONLY" ]] || ZSH_POWERLINE_SHOW_GIT_BRANCH_ONLY=false
[[ -n "$ZSH_POWERLINE_SHOW_RETURN_CODE" ]] || ZSH_POWERLINE_SHOW_RETURN_CODE=true
[[ -n "$ZSH_POWERLINE_DIRECTORY_DEPTH" ]] || ZSH_POWERLINE_DIRECTORY_DEPTH=2
# a new line before prompt
PROMPT="
"
# username
if [ $ZSH_POWERLINE_SHOW_USER = true ]; then
local USER="%n"
PROMPT="${PROMPT}${FG_COLOR_BLUE}${BG_COLOR_BASE3}${PADDING}${USER}"
PADDING=' '
fi
# hostname
if [ $ZSH_POWERLINE_SHOW_IP = true ]; then
if [ "$(echo $IP | grep 200)" = "" ]; then
IP=`curl -si --max-time 2 http://ipecho.net/plain`
# no network connection, use hostname
IP="%m"
else
# replace dot by dash
IP=`echo -n $IP | tail -n 1 | sed "s/\./-/g"`
fi
if [ $ZSH_POWERLINE_SHOW_USER = true ]; then
PROMPT="${PROMPT}${FG_COLOR_GREEN}${BG_COLOR_BASE3} at"
fi
PROMPT="${PROMPT}${FG_COLOR_VIOLET}${BG_COLOR_BASE3}${PADDING}${IP}"
PADDING=' '
fi
# arrow symbol for username and ip/host
if [ $ZSH_POWERLINE_SHOW_USER = true ] || [ $ZSH_POWERLINE_SHOW_IP = true ]; then
if [ $ZSH_POWERLINE_SHOW_TIME = true ]; then
PROMPT="${PROMPT} ${FG_COLOR_BASE3}${BG_COLOR_BASE01}${ARROW_SYMBOL}"
else
PROMPT="${PROMPT} ${FG_COLOR_BASE3}${BG_COLOR_BASE02}${ARROW_SYMBOL}"
fi
fi
# datetime
if [ $ZSH_POWERLINE_SHOW_TIME = true ]; then
PROMPT="${PROMPT}${FG_COLOR_BASE3}${BG_COLOR_BASE01}${PADDING}${ZSH_TIME}"
PROMPT="${PROMPT} ${FG_COLOR_BASE01}${BG_COLOR_BASE02}${ARROW_SYMBOL}"
PADDING=' '
fi
# OS logo
if [ $ZSH_POWERLINE_SHOW_OS = true ]; then
PROMPT="${PROMPT}${FG_COLOR_BASE3}${BG_COLOR_BASE02}${PADDING}${LOGO}"
PADDING=' '
fi
# current directory (%E hightline all line to end)
DIRECOTORY_DEPTH="%${ZSH_POWERLINE_DIRECTORY_DEPTH}~"
PROMPT="${PROMPT}${FG_COLOR_BASE3}${BG_COLOR_BASE02} ${DIRECOTORY_DEPTH}"
# show git status
if [ $ZSH_POWERLINE_SHOW_GIT_BRANCH_ONLY = true ]; then
# get git branch function
git_branch() {
git rev-parse --git-dir > /dev/null 2>&1
if [ "$?" = "0" ]; then
BRANCH=$(git branch | grep '*' | cut -d' ' -f2-)
echo ${ZSH_THEME_GIT_PROMPT_PREFIX}${BRANCH}
fi
}
PROMPT="${PROMPT}"'$(git_branch)'
elif [ $ZSH_POWERLINE_SHOW_GIT_STATUS = true ]; then
PROMPT="${PROMPT}"'$(git_prompt_info)'
fi
# single line or double lines
if [ $ZSH_POWERLINE_SINGLE_LINE = false ]; then
PROMPT="${PROMPT} %E
${RESET}${FG_COLOR_BASE02}${ARROW_SYMBOL}"
else
PROMPT="${PROMPT} ${RESET}${FG_COLOR_BASE02}${ARROW_SYMBOL}"
fi
# reset
PROMPT="$PROMPT ${RESET}"
if [ $ZSH_POWERLINE_SHOW_RETURN_CODE = true ]; then
RPROMPT="${RETURN_CODE}"
fi