p10k.zsh 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. if [[ $__p9k_sourced != 13 ]]; then
  2. return
  3. fi
  4. __prompt_themed=true
  5. if gitstatusd=$(which gitstatusd); then
  6. export GITSTATUS_DAEMON="$gitstatusd"
  7. fi
  8. # Tip: Looking for a nice color? Here's a one-liner to print colormap.
  9. #
  10. # for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done
  11. # Temporarily change options.
  12. 'builtin' 'local' '-a' 'p10k_config_opts'
  13. [[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
  14. [[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
  15. [[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
  16. 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
  17. () {
  18. emulate -L zsh -o extended_glob
  19. # Unset all configuration options. This allows you to apply configuration changes without
  20. # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
  21. unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
  22. # Zsh >= 5.1 is required.
  23. autoload -Uz is-at-least && is-at-least 5.1 || return
  24. # The list of segments shown on the left. Fill it with the most important segments.
  25. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
  26. # =========================[ Line #1 ]=========================
  27. time # current time
  28. context # user@hostname
  29. dir # current directory
  30. vcs # git status
  31. # =========================[ Line #2 ]=========================
  32. newline # \n
  33. prompt_char # prompt symbol
  34. )
  35. # The list of segments shown on the right. Fill it with less important segments.
  36. # Right prompt on the last prompt line (where you are typing your commands) gets
  37. # automatically hidden when the input line reaches it. Right prompt above the
  38. # last prompt line gets hidden if it would overlap with left prompt.
  39. typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
  40. # =========================[ Line #1 ]=========================
  41. status # exit code of the last command
  42. command_execution_time # duration of the last command
  43. background_jobs # presence of background jobs
  44. kubecontext # current kubernetes context (https://kubernetes.io/)
  45. aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
  46. nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html)
  47. )
  48. # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you.
  49. typeset -g POWERLEVEL9K_MODE=ascii
  50. # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid
  51. # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added.
  52. typeset -g POWERLEVEL9K_ICON_PADDING=none
  53. # Basic style options that define the overall look of your prompt. You probably don't want to
  54. # change them.
  55. typeset -g POWERLEVEL9K_BACKGROUND= # transparent background
  56. typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace
  57. typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space
  58. typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol
  59. typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true
  60. # Add an empty line before each prompt.
  61. typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
  62. # Connect left prompt lines with these symbols.
  63. typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=
  64. typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX=
  65. typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX=
  66. # Connect right prompt lines with these symbols.
  67. typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX=
  68. typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX=
  69. typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX=
  70. # The left end of left prompt.
  71. typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=
  72. # The right end of right prompt.
  73. typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL=
  74. # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll
  75. # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and
  76. # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below.
  77. typeset -g POWERLEVEL9K_SHOW_RULER=false
  78. typeset -g POWERLEVEL9K_RULER_CHAR='-' # reasonable alternative: '·'
  79. typeset -g POWERLEVEL9K_RULER_FOREGROUND=7
  80. # Filler between left and right prompt on the first prompt line. You can set it to '·' or '-'
  81. # to make it easier to see the alignment between left and right prompt and to separate prompt
  82. # from command output. It serves the same purpose as ruler (see above) without increasing
  83. # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false
  84. # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact
  85. # prompt.
  86. typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '
  87. if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then
  88. # The color of the filler.
  89. typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=7
  90. # Add a space between the end of left prompt and the filler.
  91. typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' '
  92. # Add a space between the filler and the start of right prompt.
  93. typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' '
  94. # Start filler from the edge of the screen if there are no left segments on the first line.
  95. typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}'
  96. # End filler on the edge of the screen if there are no right segments on the first line.
  97. typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}'
  98. fi
  99. ################################[ prompt_char: prompt symbol ]################################
  100. # Green prompt symbol if the last command succeeded.
  101. typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=f
  102. # Red prompt symbol if the last command failed.
  103. typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=f
  104. # Default prompt symbol.
  105. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='%%'
  106. # Prompt symbol in command vi mode.
  107. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='<'
  108. # Prompt symbol in visual vi mode.
  109. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
  110. # Prompt symbol in overwrite vi mode.
  111. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='^'
  112. typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
  113. # No line terminator if prompt_char is the last segment.
  114. typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
  115. # No line introducer if prompt_char is the first segment.
  116. typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=
  117. ##################################[ dir: current directory ]##################################
  118. # Default current directory color.
  119. typeset -g POWERLEVEL9K_DIR_FOREGROUND=3
  120. # If directory is too long, shorten some of its segments to the shortest possible unique
  121. # prefix. The shortened directory can be tab-completed to the original.
  122. typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique
  123. # Replace removed segment suffixes with this symbol.
  124. typeset -g POWERLEVEL9K_SHORTEN_DELIMITER=
  125. # Color of the shortened directory segments.
  126. typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=3
  127. # Color of the anchor directory segments. Anchor segments are never shortened. The first
  128. # segment is always an anchor.
  129. typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=3
  130. # Set to true to display anchor directory segments in bold.
  131. typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=false
  132. # Don't shorten directories that contain any of these files. They are anchors.
  133. local anchor_files=(
  134. .bzr
  135. .citc
  136. .git
  137. .hg
  138. .node-version
  139. .python-version
  140. .go-version
  141. .ruby-version
  142. .lua-version
  143. .java-version
  144. .perl-version
  145. .php-version
  146. .tool-version
  147. .shorten_folder_marker
  148. .svn
  149. .terraform
  150. CVS
  151. Cargo.toml
  152. composer.json
  153. go.mod
  154. package.json
  155. stack.yaml
  156. )
  157. typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
  158. # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains
  159. # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
  160. # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
  161. # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
  162. # and other directories don't.
  163. #
  164. # Optionally, "first" and "last" can be followed by ":<offset>" where <offset> is an integer.
  165. # This moves the truncation point to the right (positive offset) or to the left (negative offset)
  166. # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0"
  167. # respectively.
  168. typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
  169. # Don't shorten this many last directory segments. They are anchors.
  170. typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
  171. # Shorten directory if it's longer than this even if there is space for it. The value can
  172. # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty,
  173. # directory will be shortened only when prompt doesn't fit or when other parameters demand it
  174. # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below).
  175. # If set to `0`, directory will always be shortened to its minimum length.
  176. typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80
  177. # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this
  178. # many columns for typing commands.
  179. typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40
  180. # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least
  181. # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands.
  182. typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50
  183. # If set to true, embed a hyperlink into the directory. Useful for quickly
  184. # opening a directory in the file manager simply by clicking the link.
  185. # Can also be handy when the directory is shortened, as it allows you to see
  186. # the full directory that was used in previous commands.
  187. typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
  188. # Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and
  189. # POWERLEVEL9K_DIR_CLASSES below.
  190. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2
  191. # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON
  192. # and POWERLEVEL9K_DIR_CLASSES below.
  193. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3
  194. # The default icon shown next to non-writable and non-existent directories when
  195. # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
  196. # typeset -g POWERLEVEL9K_LOCK_ICON='⭐'
  197. # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
  198. # directories. It must be an array with 3 * N elements. Each triplet consists of:
  199. #
  200. # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with
  201. # extended_glob option enabled.
  202. # 2. Directory class for the purpose of styling.
  203. # 3. An empty string.
  204. #
  205. # Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
  206. #
  207. # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
  208. # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
  209. #
  210. # For example, given these settings:
  211. #
  212. # typeset -g POWERLEVEL9K_DIR_CLASSES=(
  213. # '~/work(|/*)' WORK ''
  214. # '~(|/*)' HOME ''
  215. # '*' DEFAULT '')
  216. #
  217. # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
  218. # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
  219. # WORK_NON_EXISTENT.
  220. #
  221. # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
  222. # option to define custom colors and icons for different directory classes.
  223. #
  224. # # Styling for WORK.
  225. # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐'
  226. # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=4
  227. # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=4
  228. # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=4
  229. #
  230. # # Styling for WORK_NOT_WRITABLE.
  231. # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
  232. # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=4
  233. # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=4
  234. # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=4#
  235. #
  236. # Styling for WORK_NON_EXISTENT.
  237. # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐'
  238. # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=4
  239. # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=4
  240. # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=4
  241. #
  242. # If a styling parameter isn't explicitly defined for some class, it falls back to the classless
  243. # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
  244. # back to POWERLEVEL9K_DIR_FOREGROUND.
  245. #
  246. typeset -g POWERLEVEL9K_DIR_CLASSES=()
  247. # Custom prefix.
  248. # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin '
  249. #####################################[ vcs: git status ]######################################
  250. # Formatter for Git status.
  251. #
  252. # Example output: master <42>42 *42 merge ~42 +42 !42 ?42.
  253. #
  254. # You can edit the function to customize how Git status looks.
  255. #
  256. # VCS_STATUS_* parameters are set by gitstatus plugin. See reference:
  257. # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
  258. function my_git_formatter() {
  259. emulate -L zsh
  260. if [[ -n $P9K_CONTENT ]]; then
  261. # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from
  262. # gitstatus plugin). VCS_STATUS_* parameters are not available in this case.
  263. typeset -g my_git_format=$P9K_CONTENT
  264. return
  265. fi
  266. if (( $1 == 0 )); then
  267. typeset -g my_git_format='(loading)'
  268. return
  269. fi
  270. local res
  271. local current
  272. local meta
  273. if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
  274. current=$VCS_STATUS_LOCAL_BRANCH
  275. meta=''
  276. elif [[ -n $VCS_STATUS_TAG ]]; then
  277. current=$VCS_STATUS_TAG
  278. meta='#'
  279. else
  280. current=${VCS_STATUS_COMMIT[1,8]}
  281. meta='@'
  282. fi
  283. res+="%f($meta%B%F{magenta}$current%f%b"
  284. (( VCS_STATUS_COMMITS_AHEAD )) && res+="^${VCS_STATUS_COMMITS_AHEAD}"
  285. (( VCS_STATUS_COMMITS_BEHIND )) && res+="v${VCS_STATUS_COMMITS_BEHIND}"
  286. res+="|"
  287. (( VCS_STATUS_NUM_STAGED )) && res+="%F{green}+${VCS_STATUS_NUM_STAGED}%f"
  288. (( VCS_STATUS_NUM_CONFLICTED )) && res+="%F{red}x${VCS_STATUS_NUM_CONFLICTED}%f"
  289. (( VCS_STATUS_NUM_UNSTAGED )) && res+="%F{red}+${VCS_STATUS_NUM_UNSTAGED}%f"
  290. (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+="%F{red}+?%f"
  291. (( VCS_STATUS_HAS_UNTRACKED )) && res+=".."
  292. (( VCS_STATUS_HAS_STAGED + VCS_STATUS_HAS_UNSTAGED + VCS_STATUS_HAS_CONFLICTED + VCS_STATUS_HAS_UNTRACKED == 0 )) && res+="%F{green}%Bok%f%b"
  293. res+=")"
  294. typeset -g my_git_format=$res
  295. }
  296. functions -M my_git_formatter 2>/dev/null
  297. # Don't count the number of unstaged, untracked and conflicted files in Git repositories with
  298. # more than this many files in the index. Negative value means infinity.
  299. #
  300. # If you are working in Git repositories with tens of millions of files and seeing performance
  301. # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output
  302. # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's
  303. # config: `git config bash.showDirtyState false`.
  304. typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1
  305. # Don't show Git status in prompt for repositories whose workdir matches this pattern.
  306. # For example, if set to '~', the Git repository at $HOME/.git will be ignored.
  307. # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
  308. typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
  309. # Disable the default Git status formatting.
  310. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
  311. # Install our own Git status formatter.
  312. typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}'
  313. typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}'
  314. # Enable counters for staged, unstaged, etc.
  315. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
  316. # Icon color.
  317. typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=2
  318. typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=
  319. # Custom icon.
  320. typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION=
  321. # Custom prefix.
  322. # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon '
  323. # Show status of repositories of these types. You can add svn and/or hg if you are
  324. # using them. If you do, your prompt may become slow even when your current directory
  325. # isn't in an svn or hg reposotiry.
  326. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
  327. # These settings are used for repositories other than Git or when gitstatusd fails and
  328. # Powerlevel10k has to fall back to using vcs_info.
  329. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=f
  330. typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=f
  331. typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=f
  332. ##########################[ status: exit code of the last command ]###########################
  333. # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and
  334. # style them independently from the regular OK and ERROR state.
  335. typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true
  336. # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as
  337. # it will signify success by turning green.
  338. typeset -g POWERLEVEL9K_STATUS_OK=false
  339. typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2
  340. typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='ok'
  341. # Status when some part of a pipe command fails but the overall exit status is zero. It may look
  342. # like this: 1|0.
  343. typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true
  344. typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2
  345. typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='ok'
  346. # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as
  347. # it will signify error by turning red.
  348. typeset -g POWERLEVEL9K_STATUS_ERROR=false
  349. typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=1
  350. typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='err'
  351. # Status when the last command was terminated by a signal.
  352. typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true
  353. typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=1
  354. # Use terse signal names: "INT" instead of "SIGINT(2)".
  355. typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false
  356. typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION=
  357. # Status when some part of a pipe command fails and the overall exit status is also non-zero.
  358. # It may look like this: 1|0.
  359. typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true
  360. typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=1
  361. typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='err'
  362. ###################[ command_execution_time: duration of the last command ]###################
  363. # Show duration of the last command if takes at least this many seconds.
  364. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
  365. # Show this many fractional digits. Zero means round to seconds.
  366. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
  367. # Execution time color.
  368. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=3
  369. # Duration format: 1d 2h 3m 4s.
  370. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
  371. # Custom icon.
  372. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION=
  373. # Custom prefix.
  374. # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook '
  375. #######################[ background_jobs: presence of background jobs ]#######################
  376. # Don't show the number of background jobs.
  377. typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
  378. # Background jobs color.
  379. typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=1
  380. # Custom icon.
  381. # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐'
  382. #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]##
  383. # Nix shell color.
  384. typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=4
  385. # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line.
  386. typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION=
  387. # Custom icon.
  388. # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐'
  389. ##################################[ context: user@hostname ]##################################
  390. # Context color when running with privileges.
  391. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1
  392. # Context color in SSH without privileges.
  393. typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=7
  394. # Default context color (no privileges, no SSH).
  395. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=7
  396. # Context format when running with privileges: bold user@hostname.
  397. typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m'
  398. # Context format when in SSH without privileges: user@hostname.
  399. typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%F{yellow}%B%n%b%f@%F{blue}%B%m%b%f'
  400. # Default context format (no privileges, no SSH): user@hostname.
  401. typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE=''
  402. # Don't show context unless running with privileges or in SSH.
  403. # Tip: Remove the next line to always show context.
  404. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION=
  405. # Custom icon.
  406. # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐'
  407. # Custom prefix.
  408. # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith '
  409. #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
  410. # Show kubecontext only when the the command you are typing invokes one of these tools.
  411. # Tip: Remove the next line to always show kubecontext.
  412. # typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|fluxctl|stern'
  413. if [ "$IN_K8S" != "true" ]; then
  414. typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND=''
  415. fi
  416. # Kubernetes context classes for the purpose of using different colors, icons and expansions with
  417. # different contexts.
  418. #
  419. # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element
  420. # in each pair defines a pattern against which the current kubernetes context gets matched.
  421. # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
  422. # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters,
  423. # you'll see this value in your prompt. The second element of each pair in
  424. # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The
  425. # first match wins.
  426. #
  427. # For example, given these settings:
  428. #
  429. # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=(
  430. # '*prod*' PROD
  431. # '*test*' TEST
  432. # '*' DEFAULT)
  433. #
  434. # If your current kubernetes context is "deathray-testing/default", its class is TEST
  435. # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'.
  436. #
  437. # You can define different colors, icons and content expansions for different classes:
  438. #
  439. # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=3
  440. # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
  441. # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
  442. typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=(
  443. # '*prod*' PROD # These values are examples that are unlikely
  444. # '*test*' TEST # to match your needs. Customize them as needed.
  445. '*' DEFAULT)
  446. typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=f
  447. typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION=''
  448. # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext
  449. # segment. Parameter expansions are very flexible and fast, too. See reference:
  450. # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion.
  451. #
  452. # Within the expansion the following parameters are always available:
  453. #
  454. # - P9K_CONTENT The content that would've been displayed if there was no content
  455. # expansion defined.
  456. # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the
  457. # output of `kubectl config get-contexts`.
  458. # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the
  459. # output of `kubectl config get-contexts`.
  460. # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
  461. # in the output of `kubectl config get-contexts`. If there is no
  462. # namespace, the parameter is set to "default".
  463. # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
  464. # output of `kubectl config get-contexts`.
  465. #
  466. # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
  467. # the following extra parameters are available:
  468. #
  469. # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks".
  470. # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID.
  471. # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone.
  472. # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster.
  473. #
  474. # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example,
  475. # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01":
  476. #
  477. # - P9K_KUBECONTEXT_CLOUD_NAME=gke
  478. # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account
  479. # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a
  480. # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01
  481. #
  482. # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01":
  483. #
  484. # - P9K_KUBECONTEXT_CLOUD_NAME=eks
  485. # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012
  486. # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1
  487. # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01
  488. typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='['
  489. # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME.
  490. POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='%F{magenta}${P9K_KUBECONTEXT_NAME}%f'
  491. POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='|'
  492. POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='%F{blue}${P9K_KUBECONTEXT_NAMESPACE}%f'
  493. POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+=']'
  494. # Custom prefix.
  495. typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%f'
  496. #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]#
  497. # Show aws only when the the command you are typing invokes one of these tools.
  498. # Tip: Remove the next line to always show aws.
  499. # typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt'
  500. # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element
  501. # in each pair defines a pattern against which the current AWS profile gets matched.
  502. # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
  503. # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters,
  504. # you'll see this value in your prompt. The second element of each pair in
  505. # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The
  506. # first match wins.
  507. #
  508. # For example, given these settings:
  509. #
  510. # typeset -g POWERLEVEL9K_AWS_CLASSES=(
  511. # '*prod*' PROD
  512. # '*test*' TEST
  513. # '*' DEFAULT)
  514. #
  515. # If your current AWS profile is "company_test", its class is TEST
  516. # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'.
  517. #
  518. # You can define different colors, icons and content expansions for different classes:
  519. #
  520. # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=2
  521. # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
  522. # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
  523. typeset -g POWERLEVEL9K_AWS_CLASSES=(
  524. # '*prod*' PROD # These values are examples that are unlikely
  525. # '*test*' TEST # to match your needs. Customize them as needed.
  526. '*' DEFAULT)
  527. typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=f
  528. typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION=''
  529. typeset -g POWERLEVEL9K_AWS_DEFAULT_CONTENT_EXPANSION='[%F{yellow}${P9K_CONTENT}%f]'
  530. ####################################[ time: current time ]####################################
  531. # Current time color.
  532. typeset -g POWERLEVEL9K_TIME_FOREGROUND=6
  533. # Format for the current time: 09:51:02. See `man 3 strftime`.
  534. typeset -g POWERLEVEL9K_TIME_FORMAT='[%D{%H:%M}]'
  535. typeset -g POWERLEVEL9K_TIME_CONTENT_EXPANSION='%B${P9K_CONTENT}'
  536. # If set to true, time will update when you hit enter. This way prompts for the past
  537. # commands will contain the start times of their commands as opposed to the default
  538. # behavior where they contain the end times of their preceding commands.
  539. typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=true
  540. # Custom icon.
  541. typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION=
  542. # Custom prefix.
  543. # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat '
  544. # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt
  545. # when accepting a command line. Supported values:
  546. #
  547. # - off: Don't change prompt when accepting a command line.
  548. # - always: Trim down prompt when accepting a command line.
  549. # - same-dir: Trim down prompt when accepting a command line unless this is the first command
  550. # typed after changing current working directory.
  551. typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off
  552. # Instant prompt mode.
  553. #
  554. # - off: Disable instant prompt. Choose this if you've tried instant prompt and found
  555. # it incompatible with your zsh configuration files.
  556. # - quiet: Enable instant prompt and don't print warnings when detecting console output
  557. # during zsh initialization. Choose this if you've read and understood
  558. # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.
  559. # - verbose: Enable instant prompt and print a warning when detecting console output during
  560. # zsh initialization. Choose this if you've never tried instant prompt, haven't
  561. # seen the warning, or if you are unsure what this all means.
  562. typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose
  563. # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
  564. # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload
  565. # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you
  566. # really need it.
  567. typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
  568. # If p10k is already loaded, reload configuration.
  569. # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true.
  570. (( ! $+functions[p10k] )) || p10k reload
  571. }
  572. # Tell `p10k configure` which file it should overwrite.
  573. typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a}
  574. (( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
  575. 'builtin' 'unset' 'p10k_config_opts'