p10k.zsh 31 KB

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