diff --git a/README.md b/README.md index 32e606caa..f7fce12c5 100644 --- a/README.md +++ b/README.md @@ -297,6 +297,7 @@ enable as many segments as you like. It won't slow down your prompt or Zsh start | `laravel_version` | [laravel php framework](https://laravel.com/) version | | `java_version` | [java](https://www.java.com/) version | | `package` | `name@version` from [package.json](https://docs.npmjs.com/files/package.json) | +| `docker` | current number of running and exited [docker](https://docker.io/) containers | | `kubecontext` | current [kubernetes](https://kubernetes.io/) context | | `terraform` | [terraform](https://www.terraform.io) workspace | | `aws` | [aws profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) | diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 731d6cd9c..f30db8b55 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -100,6 +100,7 @@ # battery # internal battery # wifi # wifi speed # example # example user-defined segment (see prompt_example function below) + # docker # Docker containers running and exited (https://www.docker.io) ) # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. @@ -274,6 +275,13 @@ # the full directory that was used in previous commands. typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + # If POWERLEVEL9K_DIR_HYPERLINK is true and using WSL, then set this to make the links work: + # You must also map this drive letter on the windows side: + # ``` + # net use L: \\wsl$\Ubuntu-20.04 /persistent:yes + # ``` + # typeset -g POWERLEVEL9K_WSL_NETWORK_DRIVE=L: + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON # and POWERLEVEL9K_DIR_CLASSES below. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 @@ -1192,6 +1200,14 @@ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ docker: shows the whale when online, and the # running and exited containers (https://www.docker.io/) ]############# + # typeset -g POWERLEVEL9K_DOCKER_ICON='🐳' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_PAUSE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_EXIT_ICON='' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index 58a691f44..e9a84c215 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -99,6 +99,7 @@ # battery # internal battery # wifi # wifi speed # example # example user-defined segment (see prompt_example function below) + # docker # Docker containers running and exited (https://www.docker.io) ) # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. @@ -268,6 +269,13 @@ # the full directory that was used in previous commands. typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + # If POWERLEVEL9K_DIR_HYPERLINK is true and using WSL, then set this to make the links work: + # You must also map this drive letter on the windows side: + # ``` + # net use L: \\wsl$\Ubuntu-20.04 /persistent:yes + # ``` + # typeset -g POWERLEVEL9K_WSL_NETWORK_DRIVE=L: + # Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and # POWERLEVEL9K_DIR_CLASSES below. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 @@ -1140,6 +1148,14 @@ # Custom icon. # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ docker: shows the whale when online, and the # running and exited containers (https://www.docker.io/) ]############# + # typeset -g POWERLEVEL9K_DOCKER_ICON='🐳' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_PAUSE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_EXIT_ICON='' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index b5e148e02..37c8119b3 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -99,6 +99,7 @@ # battery # internal battery # wifi # wifi speed # example # example user-defined segment (see prompt_example function below) + # docker # Docker containers running and exited (https://www.docker.io) ) # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. @@ -268,6 +269,13 @@ # the full directory that was used in previous commands. typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + # If POWERLEVEL9K_DIR_HYPERLINK is true and using WSL, then set this to make the links work: + # You must also map this drive letter on the windows side: + # ``` + # net use L: \\wsl$\Ubuntu-20.04 /persistent:yes + # ``` + # typeset -g POWERLEVEL9K_WSL_NETWORK_DRIVE=L: + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON # and POWERLEVEL9K_DIR_CLASSES below. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 @@ -1136,6 +1144,14 @@ # Custom icon. # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ docker: shows the whale when online, and the # running and exited containers (https://www.docker.io/) ]############# + # typeset -g POWERLEVEL9K_DOCKER_ICON='🐳' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_PAUSE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_EXIT_ICON='' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index 06d1426de..32daae986 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -100,6 +100,7 @@ # battery # internal battery # wifi # wifi speed # example # example user-defined segment (see prompt_example function below) + # docker # Docker containers running and exited (https://www.docker.io) ) # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. @@ -274,6 +275,13 @@ # the full directory that was used in previous commands. typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + # If POWERLEVEL9K_DIR_HYPERLINK is true and using WSL, then set this to make the links work: + # You must also map this drive letter on the windows side: + # ``` + # net use L: \\wsl$\Ubuntu-20.04 /persistent:yes + # ``` + # typeset -g POWERLEVEL9K_WSL_NETWORK_DRIVE=L: + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON # and POWERLEVEL9K_DIR_CLASSES below. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 @@ -1258,6 +1266,20 @@ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_BACKGROUND=0 # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ docker: shows the whale when online, and the # running and exited containers (https://www.docker.io/) ]############# + # typeset -g POWERLEVEL9K_DOCKER_ICON='🐳' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_PAUSE_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_EXIT_ICON='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_VISUAL_IDENTIFIER_EXPANSION='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_VISUAL_IDENTIFIER_EXPANSION='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_ONLINE_VISUAL_IDENTIFIER_EXPANSION='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_PAUSE_VISUAL_IDENTIFIER_EXPANSION='' + # typeset -g POWERLEVEL9K_DOCKER_CONTAINER_EXIT_VISUAL_IDENTIFIER_EXPANSION='' + # typeset -g POWERLEVEL9K_DOCKER_CONTENT_EXPANSION='${DOCKER_ONLINE_CONTENT_EXPANSION}${DOCKER_PAUSE_CONTENT_EXPANSION}${DOCKER_EXIT_CONTENT_EXPANSION}' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. diff --git a/internal/icons.zsh b/internal/icons.zsh index 532ab0a6a..7ad121892 100644 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -49,6 +49,7 @@ function _p9k_init_icons() { ANDROID_ICON '\uE270'$s #  LINUX_ICON '\uE271'$s #  LINUX_ARCH_ICON '\uE271'$s #  + LINUX_KALI_ICON '\uE271'$s #  LINUX_DEBIAN_ICON '\uE271'$s #  LINUX_RASPBIAN_ICON '\uE271'$s #  LINUX_UBUNTU_ICON '\uE271'$s #  @@ -97,6 +98,8 @@ function _p9k_init_icons() { VCS_LOADING_ICON '' VCS_GIT_ICON '\uE20E ' #  VCS_GIT_GITHUB_ICON '\uE20E ' # + VCS_GIT_GITHUB2_ICON '\uE20E ' # + VCS_GIT_GITHUB3_ICON '\uE20E ' # VCS_GIT_BITBUCKET_ICON '\uE20E ' # VCS_GIT_GITLAB_ICON '\uE20E ' # VCS_HG_ICON '\uE1C3 ' #  @@ -144,6 +147,10 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' + DOCKER_ICON '\UE7B0' + DOCKER_CONTAINER_ONLINE_ICON '\UF674' + DOCKER_CONTAINER_PAUSE_ICON '\UF04C' #  + DOCKER_CONTAINER_EXIT_ICON '\UF00D' ) ;; 'awesome-fontconfig') @@ -181,6 +188,7 @@ function _p9k_init_icons() { ANDROID_ICON '\uE17B'$s #  (doesn't always work) LINUX_ICON '\uF17C'$s #  LINUX_ARCH_ICON '\uF17C'$s #  + LINUX_KALI_ICON '\u327F'$s # ㉿ LINUX_DEBIAN_ICON '\uF17C'$s #  LINUX_RASPBIAN_ICON '\uF17C'$s #  LINUX_UBUNTU_ICON '\uF17C'$s #  @@ -225,6 +233,8 @@ function _p9k_init_icons() { VCS_LOADING_ICON '' VCS_GIT_ICON '\uF1D3 ' #  VCS_GIT_GITHUB_ICON '\uF113 ' #  + VCS_GIT_GITHUB2_ICON '\uF09B ' #  + VCS_GIT_GITHUB3_ICON '\uF092 ' #  VCS_GIT_BITBUCKET_ICON '\uF171 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  @@ -272,6 +282,10 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' + DOCKER_ICON '\UE7B0' + DOCKER_CONTAINER_ONLINE_ICON '\UF674' + DOCKER_CONTAINER_PAUSE_ICON '\UF04C' #  + DOCKER_CONTAINER_EXIT_ICON '\UF00D' ) ;; 'awesome-mapped-fontconfig') @@ -314,6 +328,7 @@ function _p9k_init_icons() { FREEBSD_ICON '\U1F608'$q # 😈 LINUX_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_ARCH_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" + LINUX_KALI_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_DEBIAN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_RASPBIAN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_UBUNTU_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" @@ -358,6 +373,8 @@ function _p9k_init_icons() { VCS_LOADING_ICON '' VCS_GIT_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" VCS_GIT_GITHUB_ICON "${CODEPOINT_OF_AWESOME_GITHUB_ALT:+\\u$CODEPOINT_OF_AWESOME_GITHUB_ALT }" + VCS_GIT_GITHUB2_ICON "${CODEPOINT_OF_AWESOME_GITHUB_ALT:+\\u$CODEPOINT_OF_AWESOME_GITHUB_ALT }" + VCS_GIT_GITHUB3_ICON "${CODEPOINT_OF_AWESOME_GITHUB_ALT:+\\u$CODEPOINT_OF_AWESOME_GITHUB_ALT }" VCS_GIT_BITBUCKET_ICON "${CODEPOINT_OF_AWESOME_BITBUCKET:+\\u$CODEPOINT_OF_AWESOME_BITBUCKET }" VCS_GIT_GITLAB_ICON "${CODEPOINT_OF_AWESOME_GITLAB:+\\u$CODEPOINT_OF_AWESOME_GITLAB }" VCS_HG_ICON "${CODEPOINT_OF_AWESOME_FLASK:+\\u$CODEPOINT_OF_AWESOME_FLASK }" @@ -403,6 +420,10 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' + DOCKER_ICON '\UE7B0' + DOCKER_CONTAINER_ONLINE_ICON '\UF674' + DOCKER_CONTAINER_PAUSE_ICON '\UF04C' + DOCKER_CONTAINER_EXIT_ICON '\UF00D' ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -440,6 +461,7 @@ function _p9k_init_icons() { FREEBSD_ICON '\UF30C ' #  ANDROID_ICON '\uF17B' #  LINUX_ARCH_ICON '\uF303' #  + LINUX_KALI_ICON '\u327F'$s # ㉿ LINUX_CENTOS_ICON '\uF304'$s #  LINUX_COREOS_ICON '\uF305'$s #  LINUX_DEBIAN_ICON '\uF306' #  @@ -485,6 +507,8 @@ function _p9k_init_icons() { VCS_LOADING_ICON '' VCS_GIT_ICON '\uF1D3 ' #  VCS_GIT_GITHUB_ICON '\uF113 ' #  + VCS_GIT_GITHUB2_ICON '\uF09B ' #  + VCS_GIT_GITHUB3_ICON '\uF092 ' #  VCS_GIT_BITBUCKET_ICON '\uE703 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  @@ -532,6 +556,10 @@ function _p9k_init_icons() { PACKAGE_ICON '\uF8D6' #  JULIA_ICON '\uE624' #  SCALA_ICON '\uE737' #  + DOCKER_ICON '\UE7B0' #  + DOCKER_CONTAINER_ONLINE_ICON '\UF674' #  + DOCKER_CONTAINER_PAUSE_ICON '\UF04C' #  + DOCKER_CONTAINER_EXIT_ICON '\UF00D' #  ) ;; ascii) @@ -567,6 +595,7 @@ function _p9k_init_icons() { ANDROID_ICON 'android' LINUX_ICON 'linux' LINUX_ARCH_ICON 'arch' + LINUX_KALI_ICON 'kali' LINUX_DEBIAN_ICON 'debian' LINUX_RASPBIAN_ICON 'pi' LINUX_UBUNTU_ICON 'ubuntu' @@ -611,6 +640,8 @@ function _p9k_init_icons() { VCS_LOADING_ICON '' VCS_GIT_ICON '' VCS_GIT_GITHUB_ICON '' + VCS_GIT_GITHUB2_ICON '' + VCS_GIT_GITHUB3_ICON '' VCS_GIT_BITBUCKET_ICON '' VCS_GIT_GITLAB_ICON '' VCS_HG_ICON '' @@ -658,6 +689,10 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' + DOCKER_ICON 'docker' + DOCKER_CONTAINER_ONLINE_ICON 'o' + DOCKER_CONTAINER_PAUSE_ICON '"' + DOCKER_CONTAINER_EXIT_ICON 'x' ) ;; *) @@ -695,6 +730,7 @@ function _p9k_init_icons() { ANDROID_ICON 'And' LINUX_ICON 'Lx' LINUX_ARCH_ICON 'Arc' + LINUX_KALI_ICON 'Kli' LINUX_DEBIAN_ICON 'Deb' LINUX_RASPBIAN_ICON 'RPi' LINUX_UBUNTU_ICON 'Ubu' @@ -739,6 +775,8 @@ function _p9k_init_icons() { VCS_LOADING_ICON '' VCS_GIT_ICON '' VCS_GIT_GITHUB_ICON '' + VCS_GIT_GITHUB2_ICON '' + VCS_GIT_GITHUB3_ICON '' VCS_GIT_BITBUCKET_ICON '' VCS_GIT_GITLAB_ICON '' VCS_HG_ICON '' @@ -786,6 +824,10 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' + DOCKER_ICON '\UE7B0' + DOCKER_CONTAINER_ONLINE_ICON '\UF674' + DOCKER_CONTAINER_PAUSE_ICON '\UF04C' #  + DOCKER_CONTAINER_EXIT_ICON '\UF00D' ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 43fa83365..4828ef3cf 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1247,6 +1247,102 @@ function _p9k_fvm_new() { return 1 } +##################################################################### +# Docker support - Appears if docker cli can talk to server. +# Shows # running and # stopped containers. +# +# Also commented with instructions on how to write an async segment. +##################################################################### +# The main prompt_ function adds the prompt segment definitions, but +# the data will be computed elsewhere. +function prompt_docker() { + # Save the length for the last line + local -i len=$#_p9k__prompt _p9k__has_upglob + + # Register the segments. Search for _p9k_left_prompt_segment for argument docs + _p9k_prompt_segment $0 NONE green DOCKER_ICON 1 '$_p9k__docker_up' '$_p9k__docker_segment' + + # Copy and paste this line; no changes needed. + (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] +} + +# The _init function must be named according to the pattern seen here. +function _p9k_prompt_docker_init() { + # Abort if the command isn't available. + (( $+commands[docker] )) || return + + # Declare global variable to hold the segment content + typeset -g _p9k__docker_segment= + typeset -g _p9k__docker_up= + + # Register this segment for async computation. Again note the pattern + _p9k__async_segments_compute+='_p9k_worker_invoke docker _p9k_prompt_docker_compute' +} + +# Runs the workers +function _p9k_prompt_docker_compute() { + (( $+commands[docker] )) || return + + # Copy and paste this line. Follow the pattern and adapt for your segment name. + _p9k_worker_async _p9k_prompt_docker_async _p9k_prompt_docker_sync + + # See the other invocations of _p9k_worker_async for examples of argument + # passing to the async impl. The sync impl should not take args. +} + +# `_async` runs the slow processes and converts the output into variables. +# +# The content will then be rendered by the segment template that was previously +# registered by the _p9k_prompt_segment in the `prompt_` function. +# +function _p9k_prompt_docker_async() { + (( $+commands[docker] )) || return + + local -A container_status_counts + container_status_counts=(E 0 U 0 P 0 S 0) + + _p9k__docker_up= + _p9k__docker_segment= + + # Minimize all use of subshells and command invocations in general. + # Async is not a license to be needlessly slow. + for line in ${(f)"$( docker ps -a --format 'table {{ .Status }}' 2>/dev/null)"}; do + if (( $? )); then break; fi + if [[ "$line" == *(Paused)* ]]; then + (( container_status_counts[P]++ )) + else + (( container_status_counts[${line:0:1}]++ )) + fi + _p9k__docker_up=1 + done + + (( ${container_status_counts[U]} )) && \ + _p9k__docker_segment="%F{green}$(print_icon 'DOCKER_CONTAINER_ONLINE_ICON') ${container_status_counts[U]} %f" + + (( ${container_status_counts[P]} )) && \ + _p9k__docker_segment+="%F{yellow}$(print_icon 'DOCKER_CONTAINER_PAUSE_ICON') ${container_status_counts[P]} %f" + + (( ${container_status_counts[E]} )) && \ + _p9k__docker_segment+="%F{red}$(print_icon 'DOCKER_CONTAINER_EXIT_ICON') ${container_status_counts[E]} %f" + + # All vars that may have changed state must be sent to _p9k_print_params + _p9k_print_params \ + _p9k__docker_segment \ + _p9k__docker_up + + # The function must end with a reset=value + echo -E - 'reset=1' +} + +# Copy, paste, and rename this function. +function _p9k_prompt_docker_sync() { + if [[ -n $REPLY ]]; then + eval $REPLY + _p9k_worker_reply $REPLY + fi +} +########################################################################## + prompt_fvm() { _p9k_fvm_new || _p9k_fvm_old } @@ -2024,15 +2120,18 @@ prompt_dir() { local content="${(pj.$sep.)parts}" if (( _POWERLEVEL9K_DIR_HYPERLINK && _p9k_term_has_href )) && [[ $_p9k__cwd == /* ]]; then - local header=$'%{\e]8;;file://'${${_p9k__cwd//\%/%%25}//'#'/%%23}$'\a%}' - local footer=$'%{\e]8;;\a%}' - if (( expand )); then - _p9k_escape $header - header=$_p9k__ret - _p9k_escape $footer - footer=$_p9k__ret + local dirpath=${${_p9k__cwd//\%/%%25}//'#'/%%23} + + if (( $+commands[wslpath] )); then + if [[ -n $_POWERLEVEL9K_WSL_NETWORK_DRIVE && $(wslpath -w ${_p9k__cwd}) == \\\\* ]]; then + dirpath=$_POWERLEVEL9K_WSL_NETWORK_DRIVE$dirpath + elif [[ $dirpath =~ '^(/(mnt/)*(.))/' ]]; then + dirpath=$match[3]:${dirpath:${#match[1]}} + fi fi - content=$header$content$footer + + _p9k_href $'file://'$dirpath $content $expand + content=$_p9k__ret fi (( expand )) && _p9k_prompt_length "${(e):-"\${\${_p9k__d::=0}+}$content"}" || _p9k__ret= @@ -2291,6 +2390,26 @@ _p9k_prompt_load_sync() { _p9k_worker_reply $REPLY } +function _p9k_href() { + local link=${${1//\%/%%25}//'#'/%%23} + local content=${2:-$1} + local expand=$3 + + local header=$'%{\e]8;;'${link}$'\a%}' + local footer=$'%{\e]8;;\a%}' + + if (( _p9k_term_has_href )) ; then + if (( expand )); then + _p9k_escape $header + header=$_p9k__ret + _p9k_escape $footer + footer=$_p9k__ret + fi + content=$header$content$footer + fi + _p9k__ret=$content +} + # Usage: _p9k_cached_cmd <0|1> [args...] # # The first argument says whether to capture stderr (1) or ignore it (0). @@ -3563,8 +3682,6 @@ function +vi-vcs-detect-changes() { vcs_visual_identifier='VCS_GIT_GITHUB_ICON' elif [[ "$remote" =~ "bitbucket" ]] then vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' - elif [[ "$remote" =~ "stash" ]] then - vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' elif [[ "$remote" =~ "gitlab" ]] then vcs_visual_identifier='VCS_GIT_GITLAB_ICON' else @@ -3706,7 +3823,6 @@ function _p9k_vcs_icon() { case "$VCS_STATUS_REMOTE_URL" in *github*) _p9k__ret=VCS_GIT_GITHUB_ICON;; *bitbucket*) _p9k__ret=VCS_GIT_BITBUCKET_ICON;; - *stash*) _p9k__ret=VCS_GIT_BITBUCKET_ICON;; *gitlab*) _p9k__ret=VCS_GIT_GITLAB_ICON;; *) _p9k__ret=VCS_GIT_ICON;; esac @@ -6335,11 +6451,8 @@ function _p9k_clear_instant_prompt() { echo -E - "${(%):- * Zsh will start %Bquickly%b but prompt will %Bjump down%b after initialization.}" echo -E - "" echo -E - "${(%):-For details, see:}" - if (( _p9k_term_has_href )); then - echo - "${(%):-\e]8;;https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt\ahttps://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt\e]8;;\a}" - else - echo - "${(%):-https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt}" - fi + _p9k_href 'https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt' + echo -E - "$_p9k__ret" echo -E - "" echo - "${(%):-%3F-- console output produced during zsh initialization follows --%f}" echo -E - "" @@ -8096,6 +8209,7 @@ function _p9k_init_cacheable() { fi case $os_release_id in *arch*) _p9k_set_os Linux LINUX_ARCH_ICON;; + *kali*) _p9k_set_os Linux LINUX_KALI_ICON;; *debian*) _p9k_set_os Linux LINUX_DEBIAN_ICON;; *raspbian*) _p9k_set_os Linux LINUX_RASPBIAN_ICON;; *ubuntu*) _p9k_set_os Linux LINUX_UBUNTU_ICON;; diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 793c8ef36..92bce3fb6 100644 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1083,6 +1083,7 @@ function os_icon_name() { fi case $os_release_id in *arch*) echo LINUX_ARCH_ICON;; + *kali*) echo LINUX_KALI_ICON;; *debian*) echo LINUX_DEBIAN_ICON;; *raspbian*) echo LINUX_RASPBIAN_ICON;; *ubuntu*) echo LINUX_UBUNTU_ICON;;