-
Notifications
You must be signed in to change notification settings - Fork 0
/
starship.theme
345 lines (288 loc) · 10.3 KB
/
starship.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
_lp_starship_theme_activate() {
local lp_terminal_format
#
# Easy to use colors.
#
local lp_terminal_format af_color='' ab_color=''
# Colors: variables are local so they will have a value only
# during config loading and will not conflict with other values
# with the same names defined by the user outside the config.
local BOLD="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${_LP_CLOSE_ESC}"
# Foreground colors
__lp_foreground_color 0
local BLACK="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local BOLD_GRAY="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 1
local RED="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local BOLD_RED="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 0
__lp_background_color 1
local WARN_RED="${_LP_OPEN_ESC}${af_color}${ab_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 7
local CRIT_RED="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${ab_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 3
local DANGER_RED="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${ab_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 2
local GREEN="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local BOLD_GREEN="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 3
local YELLOW="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local BOLD_YELLOW="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 4
local BLUE="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local BOLD_BLUE="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 5
local PURPLE="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local MAGENTA="${PURPLE}"
local PINK="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
local BOLD_PURPLE="${PINK}"
local BOLD_MAGENTA="${PINK}"
__lp_foreground_color 6
local CYAN="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local BOLD_CYAN="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
__lp_foreground_color 7
local WHITE="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
local BOLD_WHITE="${_LP_OPEN_ESC}${_LP_TI_BOLD-}${af_color}${_LP_CLOSE_ESC}"
# NO_COL is special: it will be used at runtime, not just during config loading
NO_COL="${_LP_OPEN_ESC}${_LP_TI_RESET-}${_LP_CLOSE_ESC}"
#
# End of colors section.
#
# Liquid Prompt reconfig
LP_COLOR_USER="$BOLD_YELLOW"
LP_COLOR_USER_ALT="$BOLD_YELLOW"
LP_COLOR_USER_LOGGED="$BOLD_YELLOW"
LP_COLOR_USER_ROOT="$BOLD_RED"
LP_COLOR_SHLVL="$BOLD_YELLOW"
LP_MARK_SHLVL="↕️ "
LP_COLOR_KUBECONTEXT="$BOLD_CYAN"
LP_MARK_KUBECONTEXT="☸ "
LP_COLOR_CONTAINER="$BLUE"
LP_MARK_PERM=""
LP_COLOR_PATH="$CYAN" # Starship use bold cyan, but that hides LP's hint on directories.
LP_COLOR_PATH_LAST_DIR="$BOLD_CYAN"
LP_COLOR_PATH_SEPARATOR="$CYAN"
LP_COLOR_PATH_SHORTENED="$BOLD_CYAN"
LP_COLOR_PATH_VCS_ROOT="$BOLD_CYAN"
LP_COLOR_WRITE="" # "${BOLD_CYAN}"
LP_COLOR_NOWRITE="${RED}🔒"
lp_terminal_format 105 -1 1 0 15 -1
LP_COLOR_TERRAFORM="$lp_terminal_format"
# LP_MARK_TERRAFORM="💠" # TODO in LP
LP_COLOR_MARK_SUDO="$BOLD_BLUE"
LP_COLOR_RUNTIME="$BOLD_YELLOW"
LP_COLOR_JOB_D="$BOLD_BLUE"
LP_COLOR_JOB_R="$BOLD_BLUE"
LP_COLOR_JOB_Z="$BOLD_BLUE"
LP_MARK_ADAPTER=" "
LP_MARK_BATTERY=" "
LP_COLOR_TIME="$BOLD_YELLOW"
LP_COLOR_ERR="$BOLD_RED"
LP_COLOR_MARK="$BOLD_WHITE"
# Starship Config
LP_STARSHIP_MARK_SSH="🌐"
LP_STARSHIP_MARK_SUDO="🧙 "
_lp_user
local -i user_type="$?"
# if (( user_type < 2 )); then # if user is not root
# if (( LP_ENABLE_SUDO )); then
# LP_COLOR_MARK_NO_SUDO="$LP_COLOR_MARK"
# fi
# else # root!
# if (( ! LP_ENABLE_VCS_ROOT )); then
# LP_MARK_DISABLED="$LP_MARK_DEFAULT"
# fi
# fi
# The user or connection type is not expected to change from inside the
# shell, so we build this just once.
if _lp_username_color; then
LP_USER="$lp_username_color in "
else
LP_USER=
fi
_lp_starship_hostname_color
LP_HOST="$lp_hostname_color"
# If we are running in a terminal multiplexer, brackets are colored
if _lp_multiplexer; then
LP_BRACKET_OPEN="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_MULTIPLEXER_OPEN}${NO_COL}"
LP_BRACKET_CLOSE="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_MULTIPLEXER_CLOSE}${NO_COL}"
else
LP_BRACKET_OPEN="${LP_MARK_BRACKET_OPEN}"
LP_BRACKET_CLOSE="${LP_MARK_BRACKET_CLOSE}"
fi
_lp_terminal_device
# shellcheck disable=SC2034
LP_TTYN=$lp_terminal_device
}
_lp_starship_theme_directory() {
_lp_default_theme_directory
}
_lp_starship_theme_prompt() {
_lp_starship_theme_prompt_data
_lp_starship_theme_prompt_template
}
_lp_starship_theme_prompt_data() {
# left of main prompt: space at right
if _lp_jobcount_color; then
LP_JOBS="$lp_jobcount_color "
else
LP_JOBS=
fi
# if _lp_temperature_color; then
# LP_TEMP="$lp_temperature_color "
# else
# LP_TEMP=
# fi
# if _lp_load_color; then
# LP_LOAD="$lp_load_color "
# else
# LP_LOAD=
# fi
if _lp_battery_color; then
LP_BATT="$lp_battery_color "
else
LP_BATT=
fi
# if _lp_wifi_signal_strength_color; then
# LP_WIFI="$lp_wifi_signal_strength_color "
# else
# LP_WIFI=
# fi
if _lp_time_color; then
LP_TIME="$lp_time_color "
# elif _lp_analog_time_color; then
# LP_TIME="$lp_analog_time_color "
else
LP_TIME=
fi
if _lp_sudo_active_color; then
# LP_COLOR_MARK="$lp_sudo_active_color"
LP_STARSHIP_SUDO="${LP_COLOR_MARK_SUDO}${LP_STARSHIP_MARK_SUDO}${NO_COL} "
else
LP_STARSHIP_SUDO=
fi
# if _lp_dirstack_color; then
# LP_DIRSTACK=" $lp_dirstack_color"
# else
# LP_DIRSTACK=
# fi
# in main prompt: no space
# if _lp_http_proxy_color; then
# LP_PROXY="$lp_http_proxy_color"
# else
# LP_PROXY=
# fi
if _lp_shell_level_color; then
LP_SHLVL="$lp_shell_level_color "
else
LP_SHLVL=
fi
if _lp_python_env_color ; then
LP_VENV="via $lp_python_env_color "
else
LP_VENV=
fi
if _lp_node_env_color; then
LP_NODE_VENV="via $lp_node_env_color "
else
LP_NODE_VENV=
fi
if _lp_ruby_env_color; then
LP_RUBY_VENV="via $lp_ruby_env_color "
else
LP_RUBY_VENV=
fi
if _lp_kubernetes_context_color; then
LP_KUBECONTEXT="via $lp_kubernetes_context_color "
else
LP_KUBECONTEXT=
fi
if _lp_terraform_env_color; then
LP_TFSPACE="via $lp_terraform_env_color "
else
LP_TFSPACE=
fi
if _lp_container_color; then
LP_CONTAINER="via $lp_container_color "
else
LP_CONTAINER=
fi
if _lp_software_collections_color; then
LP_SCLS="via $lp_software_collections_color "
else
LP_SCLS=
fi
if _lp_aws_profile_color; then
LP_AWS_PROFILE="via $lp_aws_profile_color "
else
LP_AWS_PROFILE=
fi
if _lp_cmake_color; then
LP_CMAKE="via $lp_cmake_color "
else
LP_CMAKE=
fi
if _lp_runtime_color; then
LP_RUNTIME="took $lp_runtime_color "
else
LP_RUNTIME=
fi
if _lp_error_color; then
LP_ERR="$lp_error_color "
else
LP_ERR=
fi
if _lp_find_vcs && _lp_vcs_details_color; then
LP_VCS="on $lp_vcs_details_color "
else
LP_VCS=
fi
# Should be called after the dev env group above.
# if _lp_dev_env_color ; then
# LP_DEV_ENV="$lp_dev_env_color"
# else
# LP_DEV_ENV=
# fi
_lp_smart_mark
LP_MARK="${lp_smart_mark}${NO_COL} "
}
_lp_starship_theme_prompt_template() {
# Starship sections:
# username, hostname, localip, shlvl, singularity, kubernetes, directory, vcsh, git_branch, git_commit, git_state, git_metrics, git_status, hg_branch, docker_context, package, c, cmake, cobol, daml, dart, deno, dotnet, elixir, elm, erlang, golang, haskell, helm, java, julia, kotlin, lua, nim, nodejs, ocaml, perl, php, pulumi, purescript, python, raku, rlang, red, ruby, rust, scala, swift, terraform, vlang, vagrant, zig, buf, nix_shell, conda, spack, memory_usage, aws, gcloud, openstack, azure, env_var, crystal, custom, sudo, cmd_duration, line_break
# jobs, battery, time, status, container, shell
# Not supported by LP:
# localip, vcsh, package, C, cobol, daml, dart, deno, dotnet, elixir, elm, erlang, golang, haskell, helm, java, julia, kotlin, lua, nim, ocaml, perl, php, pulumi, purescript, raku, rlang, red, ruby, rust, scala, swift, vlang, vagrant, zig, buf, nix_shell, conda, spack, memory_usage, gcloud, openstack, azure, env_var, crystal
# Not supported by Starship:
# load, temp, title, X11, chroot, SU, telnet, ssh color, wifi, dirstack, proxy, analog time, tmux/screen.
if [[ -f "${LP_PS1_FILE-}" ]]; then
# shellcheck source=liquid.ps1
source "$LP_PS1_FILE"
fi
if [[ -z "${LP_PS1-}" ]]; then
# Docker is displayed along with Singularity and Kubernetes (strange that it is not the case in Starship…),
# in the container section, which is not duplicated at the end, like in Starship (WTF?).
local n=$'\n'
PS1="${LP_USER}${LP_HOST}${LP_SHLVL}${LP_CONTAINER}${LP_KUBECONTEXT}${LP_PWD}${LP_PERM} ${LP_VCS}${LP_CMAKE}${LP_NODE_VENV}${LP_VENV}${LP_TFSPACE}${LP_AWS_PROFILE}${LP_PS1_POSTFIX}${LP_STARSHIP_SUDO}${LP_RUNTIME}${n}"
PS1+="${LP_JOBS}${LP_BATT}${LP_TIME}${LP_ERR}${LP_COLOR_MARK}${LP_MARK}"
# No title support in Starship.
else
PS1=$LP_PS1
fi
}
_lp_starship_hostname_color() {
# No X11 support in Starship.
# No Chroot support in Starship.
if _lp_hostname; then
case "$lp_connection" in
lcl)
lp_hostname_color+="${LP_COLOR_HOST}${lp_hostname}${NO_COL}"
;;
ssh)
# No hashed host color in Starship.
lp_hostname_color+="${LP_COLOR_SSH}${LP_STARSHIP_MARK_SSH}${NO_COL} on ${LP_COLOR_HOST}${lp_hostname}${NO_COL}"
;;
# No SU support in Starship.
# No telnet support in Starship.
esac
fi
}