This repository has been archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 938
/
Copy pathpowerlevel9k.zsh-theme
executable file
·235 lines (212 loc) · 9.49 KB
/
powerlevel9k.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
#!/usr/bin/env zsh
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
################################################################
# @title powerlevel9k Theme
# @source [powerlevel9k](https://github.com/bhilburn/powerlevel9k)
##
# @authors
# Ben Hilburn - [@bhilburn](https://github.com/bhilburn)
# Dominik Ritter - [@dritter](https://github.com/dritter)
# Christo Kotze - [@onaforeignshore](https://github.com/onaforeignshore)
##
# @info
# This theme was inspired by [agnoster's Theme](https://gist.github.com/3712874)
#
# For basic documentation, please refer to the README.md in the top-level
# directory. For more detailed documentation, refer to the
# [project wiki](https://github.com/bhilburn/powerlevel9k/wiki).
#
# There are a lot of easy ways you can customize your prompt segments and
# theming with simple variables defined in your `~/.zshrc`. Please refer to
# the `sample-zshrc` file for more details.
################################################################
# Define the version number. This will make it easier to support as users can report this with tickets.
readonly P9K_VERSION="0.7.0"
## Turn on for Debugging
# PS4='%s%f%b%k%F{blue}λ%L %F{240}%N:%i%(?.. %F{red}%?) %1(_.%F{yellow}%-1_ .)%s%f%b%k '
# zstyle ':vcs_info:*+*:*' debug true
# set -o xtrace
# Try to set the installation path
if [[ -n "$P9K_INSTALLATION_DIR" ]]; then
__P9K_DIRECTORY=${P9K_INSTALLATION_DIR:A}
else
if [[ "${(%):-%N}" == '(eval)' ]]; then
if [[ "$0" == '-antigen-load' ]] && [[ -r "${PWD}/powerlevel9k.zsh-theme" ]]; then
# Antigen uses eval to load things so it can change the plugin (!!)
# https://github.com/zsh-users/antigen/issues/581
__P9K_DIRECTORY=$PWD
else
print -P "%F{red}You must set P9K_INSTALLATION_DIR to work from within an (eval).%f"
return 1
fi
else
# Get the path to file this code is executing in; then
# get the absolute path and strip the filename.
# See https://stackoverflow.com/a/28336473/108857
__P9K_DIRECTORY=${${(%):-%x}:A:h}
fi
fi
#readonly __P9K_DIRECTORY
autoload -U is-at-least
__P9K_USE_PRINT_V=false
is-at-least 5.3 && __P9K_USE_PRINT_V=true
################################################################
# Source utility functions
################################################################
source "${__P9K_DIRECTORY}/functions/utilities.zsh"
################################################################
# Source icon functions
################################################################
source "${__P9K_DIRECTORY}/functions/icons.zsh"
################################################################
# Source color functions
################################################################
source "${__P9K_DIRECTORY}/functions/colors.zsh"
################################################################
# Color Scheme
################################################################
if [[ "$P9K_COLOR_SCHEME" == "light" ]]; then
DEFAULT_COLOR=white
DEFAULT_COLOR_INVERTED=black
else
DEFAULT_COLOR=black
DEFAULT_COLOR_INVERTED=white
fi
################################################################
# Deprecated segments and variables
################################################################
# Display a warning if deprecated segments are in use.
typeset -AH deprecated_segments
# old => new
deprecated_segments=(
'longstatus' 'status'
)
__p9k_print_deprecation_warning deprecated_segments
# Display a warning if deprecated variables have been updated.
typeset -AH deprecated_variables
# old => new
deprecated_variables=(
# General icons
# Due to the changes to `p9k::register_icon`, these now require the '_ICON' suffix to work.
'P9K_MULTILINE_FIRST_PROMPT_PREFIX' 'P9K_MULTILINE_FIRST_PROMPT_PREFIX_ICON'
'P9K_MULTILINE_LAST_PROMPT_PREFIX' 'P9K_MULTILINE_LAST_PROMPT_PREFIX_ICON'
'P9K_LEFT_SEGMENT_SEPARATOR' 'P9K_LEFT_SEGMENT_SEPARATOR_ICON'
'P9K_LEFT_SUBSEGMENT_SEPARATOR' 'P9K_LEFT_SUBSEGMENT_SEPARATOR_ICON'
'P9K_RIGHT_SEGMENT_SEPARATOR' 'P9K_RIGHT_SEGMENT_SEPARATOR_ICON'
'P9K_RIGHT_SUBSEGMENT_SEPARATOR' 'P9K_RIGHT_SUBSEGMENT_SEPARATOR_ICON'
# status icons
'P9K_OK_ICON' 'P9K_STATUS_OK_ICON'
'P9K_FAIL_ICON' 'P9K_STATUS_ERROR_ICON'
'P9K_CARRIAGE_RETURN_ICON' 'P9K_STATUS_ERROR_CR_ICON'
# aws segment
'AWS_DEFAULT_PROFILE' 'P9K_AWS_DEFAULT_PROFILE'
# aws_eb_env segment
'P9K_AWS_EB_ICON' 'P9K_AWS_EB_ENV_ICON'
# command_execution_time segment
'P9K_EXECUTION_TIME_ICON' 'P9K_COMMAND_EXECUTION_TIME_ICON'
# context segment
'P9K_ALWAYS_SHOW_CONTEXT' 'P9K_CONTEXT_ALWAYS_SHOW'
'P9K_ALWAYS_SHOW_USER' 'P9K_CONTEXT_ALWAYS_SHOW_USER'
# dir segment
'P9K_HOME_ICON' 'P9K_DIR_HOME_ICON'
'P9K_HOME_SUB_ICON' 'P9K_DIR_HOME_SUBFOLDER_ICON'
'P9K_FOLDER_ICON' 'P9K_DIR_DEFAULT_ICON'
'P9K_LOCK_ICON' 'P9K_DIR_NOT_WRITABLE_ICON'
'P9K_ETC_ICON' 'P9K_DIR_ETC_ICON'
'P9K_SHORTEN_DIR_LENGTH' 'P9K_DIR_SHORTEN_LENGTH'
'P9K_SHORTEN_STRATEGY' 'P9K_DIR_SHORTEN_STRATEGY'
'P9K_SHORTEN_DELIMITER' 'P9K_DIR_SHORTEN_DELIMITER'
'P9K_SHORTEN_FOLDER_MARKER' 'P9K_DIR_SHORTEN_FOLDER_MARKER'
'P9K_HOME_FOLDER_ABBREVIATION' 'P9K_DIR_HOME_FOLDER_ABBREVIATION'
# disk_usage segment
'P9K_DISK_ICON' 'P9K_DISK_USAGE_NORMAL_ICON,P9K_DISK_USAGE_WARNING_ICON,P9K_DISK_USAGE_CRITICAL_ICON'
# docker_machine segment
'P9K_SERVER_ICON' 'P9K_DOCKER_MACHINE_ICON'
# host segment
'P9K_HOST_ICON' 'P9K_HOST_LOCAL_ICON,P9K_HOST_REMOTE_ICON'
# ip segment
'P9K_NETWORK_ICON' 'P9K_IP_ICON'
# go_version segment
'P9K_GO_ICON' 'P9K_GO_VERSION_ICON'
# kubecontext segment
'P9K_KUBERNETES_ICON' 'P9K_KUBECONTEXT_ICON'
# load segment
'P9K_LOAD_ICON' 'P9K_LOAD_NORMAL_ICON,P9K_LOAD_WARNING_ICON,P9K_LOAD_CRITICAL_ICON'
# node_env and node_version segments
'P9K_NODE_ICON' 'P9K_NODE_ENV_ICON,P9K_NODE_VERSION_ICON'
# pyenv segment
'P9K_PYTHON_ICON' 'P9K_PYENV_ICON'
# rbenv segment
'P9K_RUBY_ICON' 'P9K_RBENV_ICON'
# rust segment
'P9K_RUST_ICON' 'P9K_RUST_VERSION_ICON'
# swift_version segment
'P9K_SWIFT_ICON' 'P9K_SWIFT_VERSION_ICON'
# user segment
'P9K_USER_ICON' 'P9K_USER_DEFAULT_ICON'
'P9K_ROOT_ICON' 'P9K_USER_ROOT_ICON'
'P9K_SUDO_ICON' 'P9K_USER_SUDO_ICON'
# vcs segment
'P9K_HIDE_BRANCH_ICON' 'P9K_VCS_HIDE_BRANCH_ICON'
'P9K_SHOW_CHANGESET' 'P9K_VCS_SHOW_CHANGESET'
'P9K_CHANGESET_HASH_LENGTH' 'P9K_VCS_CHANGESET_HASH_LENGTH'
# vi_mode segment
'P9K_VI_INSERT_MODE_STRING' 'P9K_VI_MODE_INSERT_STRING'
'P9K_VI_COMMAND_MODE_STRING' 'P9K_VI_MODE_NORMAL_STRING'
'P9K_VI_VISUAL_MODE_STRING' 'P9K_VI_MODE_VISUAL_STRING'
'P9K_VI_SEARCH_MODE_STRING' 'P9K_VI_MODE_SEARCH_STRING'
)
__p9k_print_deprecation_var_warning deprecated_variables
################################################################
# Choose the generator
################################################################
case "${(L)P9K_GENERATOR}" in
"zsh-async")
source "${__P9K_DIRECTORY}/generator/zsh-async.p9k"
;;
*)
source "${__P9K_DIRECTORY}/generator/default.p9k"
;;
esac
################################################################
# Set default prompt segments
################################################################
p9k::defined P9K_LEFT_PROMPT_ELEMENTS || P9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
p9k::defined P9K_RIGHT_PROMPT_ELEMENTS || P9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
################################################################
# Load Prompt Segment Definitions
################################################################
p9k::set_default P9K_CUSTOM_SEGMENT_LOCATION "$HOME/.config/powerlevel9k/segments"
# load only the segments that are being used!
function __p9k_load_segments() {
local segment
for segment in ${P9K_LEFT_PROMPT_ELEMENTS} ${P9K_RIGHT_PROMPT_ELEMENTS}; do
# Remove joined information
segment=${segment%_joined}
# Custom segments must be loaded by user
if [[ $segment[0,7] =~ "custom_" ]]; then
continue
fi
# check if the file exists as a core segment
if [[ -f ${__P9K_DIRECTORY}/segments/${segment}/${segment}.p9k ]]; then
source "${__P9K_DIRECTORY}/segments/${segment}/${segment}.p9k" 2>&1
else
# check if the file exists as a custom segment
if [[ -f "${P9K_CUSTOM_SEGMENT_LOCATION}/${segment}/${segment}.p9k" ]]; then
# This is not muted, as we want to show if there are issues with
# his custom segments.
source "${P9K_CUSTOM_SEGMENT_LOCATION}/${segment}/${segment}.p9k"
else
# file not found!
# If this happens, we remove the segment from the configured elements,
# so that we avoid printing errors over and over.
print -P "%F{yellow}Warning!%f The '%F{cyan}${segment}%f' segment was not found. Removing it from the prompt."
P9K_LEFT_PROMPT_ELEMENTS=("${(@)P9K_LEFT_PROMPT_ELEMENTS:#${segment}}")
P9K_RIGHT_PROMPT_ELEMENTS=("${(@)P9K_RIGHT_PROMPT_ELEMENTS:#${segment}}")
fi
fi
done
}
__p9k_load_segments
# lauch the generator (prompt)
prompt_powerlevel9k_setup "$@"