p10k.zsh 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. # vim: et ts=2 sw=2 colorcolumn=100
  2. # Generated by Powerlevel10k configuration wizard on 2020-11-26 at 18:36 EET.
  3. # Based on romkatv/powerlevel10k/config/p10k-pure.zsh, checksum 13301.
  4. # Wizard options: nerdfont-complete + powerline, small icons, pure, rpromt, 1 line,
  5. # compact, transient_prompt, instant_prompt=verbose.
  6. # Type `p10k configure` to generate another config.
  7. #
  8. # Config file for Powerlevel10k with the style of Pure (https://github.com/sindresorhus/pure).
  9. #
  10. # Differences from Pure:
  11. #
  12. # - Git:
  13. # - `@c4d3ec2c` instead of something like `v1.4.0~11` when in detached HEAD state.
  14. # - No automatic `git fetch` (the same as in Pure with `PURE_GIT_PULL=0`).
  15. #
  16. # Apart from the differences listed above, the replication of Pure prompt is exact. This includes
  17. # even the questionable parts. For example, just like in Pure, there is no indication of Git status
  18. # being stale; prompt symbol is the same in command, visual and overwrite vi modes; when prompt
  19. # doesn't fit on one line, it wraps around with no attempt to shorten it.
  20. #
  21. # If you like the general style of Pure but not particularly attached to all its quirks, type
  22. # `p10k configure` and pick "Lean" style. This will give you slick minimalist prompt while taking
  23. # advantage of Powerlevel10k features that aren't present in Pure.
  24. # Temporarily change options.
  25. 'builtin' 'local' '-a' 'p10k_config_opts'
  26. [[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
  27. [[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
  28. [[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
  29. 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
  30. () {
  31. emulate -L zsh -o extended_glob
  32. # Unset all configuration options.
  33. unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
  34. # Zsh >= 5.1 is required.
  35. autoload -Uz is-at-least && is-at-least 5.1 || return
  36. # Prompt colors.
  37. {
  38. typeset -gr __red=1
  39. typeset -gr __blue=4
  40. typeset -gr __cyan=6
  41. typeset -gr __green=2
  42. typeset -gr __white=7
  43. typeset -gr __grey=242
  44. typeset -gr __yellow=3
  45. typeset -gr __magenta=5
  46. } 2>/dev/null ||:
  47. # convert 4 char hex to unicode char: `__u 21e3`
  48. __u() printf %b "\u${1:?}"
  49. # Left prompt segments.
  50. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
  51. dir # current directory
  52. vcs # git status
  53. # command_execution_time # previous command duration
  54. # virtualenv # python virtual environment
  55. context # user@host
  56. prompt_char # prompt symbol
  57. )
  58. # Right prompt segments.
  59. typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
  60. background_jobs
  61. virtualenv # python virtual environment
  62. # time # current time
  63. ncdu
  64. lf
  65. bat
  66. command_execution_time # previous command duration
  67. torsocks
  68. status
  69. )
  70. # Basic style options that define the overall prompt look.
  71. typeset -g POWERLEVEL9K_BACKGROUND= # transparent background
  72. typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace
  73. typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space
  74. typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol
  75. # typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # no segment icons
  76. # Add an empty line before each prompt except the first. This doesn't emulate the bug
  77. # in Pure that makes prompt drift down whenever you use the Alt-C binding from fzf or similar.
  78. typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false
  79. # Magenta prompt symbol if the last command succeeded.
  80. typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND="${__magenta}"
  81. # Red prompt symbol if the last command failed.
  82. typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND="${__red}"
  83. # Default prompt symbol.
  84. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION=$(__u 227b)
  85. # Prompt symbol in command vi mode.
  86. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION=$(__u 227a)
  87. # Prompt symbol in visual vi mode is the same as in command mode.
  88. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION=$(__u 22ce)
  89. # Prompt symbol in overwrite vi mode is the same as in command mode.
  90. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION=$(__u 22cf)
  91. typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
  92. # Grey Python Virtual Environment.
  93. typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND="${__grey}"
  94. # Don't show Python version.
  95. typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
  96. typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=
  97. # Blue current directory.
  98. typeset -g POWERLEVEL9K_DIR_FOREGROUND="${__blue}"
  99. # Context format when root: user@host. The first part white, the rest grey.
  100. typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE="%F{${__white}}%n%f%F{${__grey}}@%m%f"
  101. # Context format when not root: user@host. The whole thing grey.
  102. typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE="%F{${__grey}}%n@%m%f"
  103. # Don't show context unless root or in SSH.
  104. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION=
  105. # Show previous command duration only if it's >= 5s.
  106. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5
  107. # Don't show fractional seconds. Thus, 7s rather than 7.3s.
  108. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
  109. # Duration format: 1d 2h 3m 4s.
  110. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
  111. # Yellow previous command duration.
  112. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND="${__yellow}"
  113. #####################################[ vcs: git status ]######################################
  114. # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
  115. typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=
  116. # Untracked files icon. It's really a question mark, your font isn't broken.
  117. # Change the value of this parameter to show a different icon.
  118. typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
  119. # Formatter for Git status.
  120. #
  121. # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42.
  122. #
  123. # You can edit the function to customize how Git status looks.
  124. #
  125. # VCS_STATUS_* parameters are set by gitstatus plugin. See reference:
  126. # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
  127. function my_git_formatter() {
  128. emulate -L zsh
  129. # if [[ -n $P9K_CONTENT ]]; then
  130. # # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from
  131. # # gitstatus plugin). VCS_STATUS_* parameters are not available in this case.
  132. # typeset -g my_git_format=$P9K_CONTENT
  133. # return
  134. # fi
  135. if (( $1 )); then
  136. # Styling for up-to-date Git status.
  137. local meta="%${__grey}F" # grey foreground
  138. local clean="%${__green}F" # green foreground
  139. local modified="%${__yellow}F" # yellow foreground
  140. local untracked="%${__blue}F" # blue foreground
  141. local conflicted="%${__red}F" # red foreground
  142. else
  143. # Styling for incomplete and stale Git status.
  144. local meta="%${__grey}F" # grey foreground
  145. local clean="%${__grey}F" # grey foreground
  146. local modified="%${__grey}F" # grey foreground
  147. local untracked="%${__grey}F" # grey foreground
  148. local conflicted="%${__grey}F" # grey foreground
  149. fi
  150. local res
  151. local where # branch or tag
  152. if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
  153. res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}"
  154. where=${(V)VCS_STATUS_LOCAL_BRANCH}
  155. elif [[ -n $VCS_STATUS_TAG ]]; then
  156. res+="${meta}#"
  157. where=${(V)VCS_STATUS_TAG}
  158. fi
  159. # If local branch name or tag is at most 32 characters long, show it in full.
  160. # Otherwise show the first 12 … the last 12.
  161. # Tip: To always show local branch name in full without truncation, delete the next line.
  162. (( $#where > 32 )) && where[13,-13]="…"
  163. res+="${clean}${where//\%/%%}" # escape %
  164. # Display the current Git commit if there is no branch or tag.
  165. # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line.
  166. [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
  167. # Show tracking branch name if it differs from local branch.
  168. if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
  169. res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
  170. fi
  171. # ⇣42 if behind the remote.
  172. (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}"
  173. # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
  174. (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" "
  175. (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}"
  176. # ⇠42 if behind the push remote.
  177. (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}"
  178. (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" "
  179. # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
  180. (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}"
  181. # *42 if have stashes.
  182. (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}"
  183. # 'merge' if the repo is in an unusual state.
  184. [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}"
  185. # ~42 if have merge conflicts.
  186. (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
  187. # +42 if have staged changes.
  188. (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}"
  189. # !42 if have unstaged changes.
  190. (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}"
  191. # ?42 if have untracked files. It's really a question mark, your font isn't broken.
  192. # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
  193. # Remove the next line if you don't want to see untracked files at all.
  194. (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
  195. # "─" if the number of unstaged files is unknown. This can happen due to
  196. # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower
  197. # than the number of files in the Git index, or due to bash.showDirtyState being set to false
  198. # in the repository config. The number of staged and untracked files may also be unknown
  199. # in this case.
  200. (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─"
  201. typeset -g my_git_format=$res
  202. }
  203. functions -M my_git_formatter 2>/dev/null
  204. # Don't count the number of unstaged, untracked and conflicted files in Git repositories with
  205. # more than this many files in the index. Negative value means infinity.
  206. #
  207. # If you are working in Git repositories with tens of millions of files and seeing performance
  208. # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output
  209. # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's
  210. # config: `git config bash.showDirtyState false`.
  211. typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1
  212. # Don't show Git status in prompt for repositories whose workdir matches this pattern.
  213. # For example, if set to '~', the Git repository at $HOME/.git will be ignored.
  214. # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
  215. typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
  216. # Disable the default Git status formatting.
  217. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
  218. # Install our own Git status formatter.
  219. typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}'
  220. typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}'
  221. # Enable counters for staged, unstaged, etc.
  222. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
  223. # Icon color.
  224. typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76
  225. typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244
  226. # Custom icon.
  227. # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐'
  228. # Custom prefix.
  229. # typeset -g POWERLEVEL9K_VCS_PREFIX='%248Fon '
  230. # Show status of repositories of these types. You can add svn and/or hg if you are
  231. # using them. If you do, your prompt may become slow even when your current directory
  232. # isn't in an svn or hg reposotiry.
  233. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
  234. # These settings are used for repositories other than Git or when gitstatusd fails and
  235. # Powerlevel10k has to fall back to using vcs_info.
  236. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76
  237. typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76
  238. typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178
  239. # # Grey Git prompt. This makes stale prompts indistinguishable from up-to-date ones.
  240. # typeset -g POWERLEVEL9K_VCS_FOREGROUND="${__grey}"
  241. #
  242. # # Disable async loading indicator to make directories that aren't Git repositories
  243. # # indistinguishable from large Git repositories without known state.
  244. # typeset -g POWERLEVEL9K_VCS_LOADING_TEXT=
  245. #
  246. # # Don't wait for Git status even for a millisecond, so that prompt always updates
  247. # # asynchronously when Git state changes.
  248. # typeset -g POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0
  249. #
  250. # # Cyan ahead/behind arrows.
  251. # typeset -g POWERLEVEL9K_VCS_{INCOMING,OUTGOING}_CHANGESFORMAT_FOREGROUND="${__cyan}"
  252. # # Don't show remote branch, current tag or stashes.
  253. # # typeset -g POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind)
  254. # # Don't show the branch icon.
  255. # typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=
  256. # # When in detached HEAD state, show @commit where branch normally goes.
  257. # # typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@'
  258. # # Don't show staged, unstaged, untracked indicators.
  259. # typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED}_ICON=
  260. # # Show '*' when there are staged, unstaged or untracked files.
  261. # typeset -g POWERLEVEL9K_VCS_DIRTY_ICON='*'
  262. #
  263. # local _d=$(__u 21e3) # down
  264. # local _u=$(__u 21e1) # up
  265. #
  266. # # Show '⇣' if local branch is behind remote.
  267. # typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON=":${_d}"
  268. # # Show '⇡' if local branch is ahead of remote.
  269. # typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON=":${_u}"
  270. # # Don't show the number of commits next to the ahead/behind arrows.
  271. # typeset -g POWERLEVEL9K_VCS_{COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=1
  272. # # Remove space between '⇣' and '⇡' and all trailing spaces.
  273. #
  274. # local _exp="\${\${\${P9K_CONTENT/${_d}* :${_u}/${_d}${_u}}// }//:/ }"
  275. # typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION="${_exp}"
  276. # Grey current time.
  277. typeset -g POWERLEVEL9K_TIME_FOREGROUND="${__grey}"
  278. # Format for the current time: 09:51:02. See `man 3 strftime`.
  279. typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}'
  280. # If set to true, time will update when you hit enter. This way prompts for the past
  281. # commands will contain the start times of their commands rather than the end times of
  282. # their preceding commands.
  283. typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false
  284. #######################[ background_jobs: presence of background jobs ]#######################
  285. typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION=$(__u f013)
  286. ##################################[ dir: current directory ]##################################
  287. # Default current directory color.
  288. typeset -g POWERLEVEL9K_DIR_FOREGROUND="${__blue}"
  289. # If directory is too long, shorten some of its segments to the shortest possible unique
  290. # prefix. The shortened directory can be tab-completed to the original.
  291. typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique
  292. # Replace removed segment suffixes with this symbol.
  293. typeset -g POWERLEVEL9K_SHORTEN_DELIMITER=
  294. # Color of the shortened directory segments.
  295. typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND="${__grey}"
  296. # Color of the anchor directory segments. Anchor segments are never shortened. The first
  297. # segment is always an anchor.
  298. typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND="${__cyan}"
  299. # Display anchor directory segments in bold.
  300. typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true
  301. # Don't shorten directories that contain any of these files. They are anchors.
  302. local anchor_files=(
  303. .bzr
  304. .citc
  305. .git
  306. .hg
  307. .node-version
  308. .python-version
  309. .ruby-version
  310. .shorten_folder_marker
  311. .svn
  312. .terraform
  313. CVS
  314. Cargo.toml
  315. composer.json
  316. go.mod
  317. package.json
  318. )
  319. typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
  320. # Don't shorten this many last directory segments. They are anchors.
  321. typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
  322. # Shorten directory if it's longer than this even if there is space for it. The value can
  323. # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty,
  324. # directory will be shortened only when prompt doesn't fit or when other parameters demand it
  325. # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below).
  326. # If set to `0`, directory will always be shortened to its minimum length.
  327. typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80
  328. # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this
  329. # many columns for typing commands.
  330. typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40
  331. # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least
  332. # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands.
  333. typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50
  334. # If set to true, embed a hyperlink into the directory. Useful for quickly
  335. # opening a directory in the file manager simply by clicking the link.
  336. # Can also be handy when the directory is shortened, as it allows you to see
  337. # the full directory that was used in previous commands.
  338. typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
  339. # Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and
  340. # POWERLEVEL9K_DIR_CLASSES below.
  341. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2
  342. # The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is
  343. # set to v2.
  344. typeset -g POWERLEVEL9K_LOCK_ICON=$(__u f023)
  345. # Custom prefix.
  346. typeset -g POWERLEVEL9K_DIR_PREFIX=' '
  347. # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons for different directories.
  348. # It must be an array with 3 * N elements. Each triplet consists of:
  349. #
  350. # 1. A pattern against which the current directory is matched. Matching is done with
  351. # extended_glob option enabled.
  352. # 2. Directory class for the purpose of styling.
  353. # 3. Icon.
  354. #
  355. # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. If there
  356. # are no matches, the directory will have no icon.
  357. #
  358. # Example:
  359. #
  360. # typeset -g POWERLEVEL9K_DIR_CLASSES=(
  361. # '~/work(|/*)' WORK '(╯°□°)╯︵ ┻━┻'
  362. # '~(|/*)' HOME '⌂'
  363. # '*' DEFAULT '')
  364. #
  365. # With these settings, the current directory in the prompt may look like this:
  366. #
  367. # (╯°□°)╯︵ ┻━┻ ~/work/projects/important/urgent
  368. #
  369. # Or like this:
  370. #
  371. # ⌂ ~/best/powerlevel10k
  372. #
  373. # You can also set different colors for directories of different classes. Remember to override
  374. # FOREGROUND, SHORTENED_FOREGROUND and ANCHOR_FOREGROUND for every directory class that you wish
  375. # to have its own color.
  376. #
  377. # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31
  378. # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103
  379. # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39
  380. #
  381. # typeset -g POWERLEVEL9K_DIR_CLASSES=(
  382. # '~/projects/C(|/*)' C $(__u e61e)
  383. # '~/projects/py(|/*)' PY $(__u e235)
  384. # '~/Downloads(|/*)' DL $(__u f661)
  385. # '~/Documents(|/*)' DOC $(__u f718)
  386. # '~/test(|/*)' TEST $(__u fb67)
  387. # '~/.config(|/*)' CFG $(__u f013)
  388. # )
  389. # typeset -g POWERLEVEL9K_DIR_C_FOREGROUND=69
  390. # typeset -g POWERLEVEL9K_DIR_PY_FOREGROUND=184
  391. # typeset -g POWERLEVEL9K_DIR_TEST_FOREGROUND=124
  392. # typeset -g POWERLEVEL9K_DIR_CFG_FOREGROUND=240
  393. ##########################[ status: exit code of the last command ]###########################
  394. local _ok=$(__u 2714)
  395. local _err=$(__u 2718)
  396. # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and
  397. # style them independently from the regular OK and ERROR state.
  398. typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true
  399. # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as
  400. # it will signify success by turning green.
  401. typeset -g POWERLEVEL9K_STATUS_OK=true
  402. typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70
  403. typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION=${_ok}
  404. # Status when some part of a pipe command fails but the overall exit status is zero. It may look
  405. # like this: 1|0.
  406. typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true
  407. typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70
  408. typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION=${_ok}
  409. # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as
  410. # it will signify error by turning red.
  411. typeset -g POWERLEVEL9K_STATUS_ERROR=true
  412. typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160
  413. typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION=${_err}
  414. # Status when the last command was terminated by a signal.
  415. typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true
  416. typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160
  417. # Use terse signal names: "INT" instead of "SIGINT(2)".
  418. typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false
  419. typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION=${_err}
  420. # Status when some part of a pipe command fails and the overall exit status is also non-zero.
  421. # It may look like this: 1|0.
  422. typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true
  423. typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160
  424. typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION=${_err}
  425. # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt
  426. # when accepting a command line. Supported values:
  427. #
  428. # - off: Don't change prompt when accepting a command line.
  429. # - always: Trim down prompt when accepting a command line.
  430. # - same-dir: Trim down prompt when accepting a command line unless this is the first command
  431. # typed after changing current working directory.
  432. typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off
  433. # Instant prompt mode.
  434. #
  435. # - off: Disable instant prompt. Choose this if you've tried instant prompt and found
  436. # it incompatible with your zsh configuration files.
  437. # - quiet: Enable instant prompt and don't print warnings when detecting console output
  438. # during zsh initialization. Choose this if you've read and understood
  439. # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.
  440. # - verbose: Enable instant prompt and print a warning when detecting console output during
  441. # zsh initialization. Choose this if you've never tried instant prompt, haven't
  442. # seen the warning, or if you are unsure what this all means.
  443. typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose
  444. # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
  445. # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload
  446. # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you
  447. # really need it.
  448. typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
  449. typeset -g POWERLEVEL9K_LF_FOREGROUND=72
  450. # my #
  451. typeset -g POWERLEVEL9K_TORSOCKS_ICON="$(__u fa29)"
  452. typeset -gr __POWERLEVEL9K_TORSOCKS_LIB="$(
  453. source=/usr/bin/torsocks \
  454. && [ -r "${source}" ] \
  455. && source "${source}" on >/dev/null \
  456. && printf %s "${SHLIB}"
  457. )"
  458. function prompt_torsocks() {
  459. [ "${__POWERLEVEL9K_TORSOCKS_LIB:-}" ] || return
  460. case "x${LD_PRELOAD:-}x" in *"${__POWERLEVEL9K_TORSOCKS_LIB:-}"*)
  461. p10k segment -f 93 -i "${POWERLEVEL9K_TORSOCKS_ICON:-t}"
  462. esac
  463. }
  464. function prompt_ncdu() {
  465. [ -n "${NCDU_LEVEL}" ] && p10k segment -f 240 -t "${NCDU_LEVEL} ncdu"
  466. }
  467. typeset -g POWERLEVEL9K_BATTERY_ICON="$(__u f582)"
  468. function prompt_bat() {
  469. local icon="${POWERLEVEL9K_BATTERY_ICON:-b}"
  470. local bat=/sys/class/power_supply/BAT0
  471. local IFS='' __status=''
  472. read -r __status < "${bat}/status"
  473. [ "${__status}" = 'Charging' ] && return
  474. local capacity="$(< "${bat}/capacity")"
  475. if [ "${capacity}" -le 20 ]; then
  476. p10k segment -f "${__red}" -i "${icon}" -t "${capacity}%%"
  477. elif [ "${capacity}" -le 30 ]; then
  478. p10k segment -f "${__yellow}" -i "${icon}" -t "${capacity}%%"
  479. fi
  480. }
  481. # my instant #
  482. function instant_prompt_torsocks() prompt_torsocks
  483. function instant_prompt_bat() prompt_bat
  484. function instant_prompt_ncdu() prompt_ncdu
  485. unset -f __u
  486. # If p10k is already loaded, reload configuration.
  487. # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true.
  488. (( ! $+functions[p10k] )) || p10k reload
  489. }
  490. # Tell `p10k configure` which file it should overwrite.
  491. typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a}
  492. (( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
  493. 'builtin' 'unset' 'p10k_config_opts'