From f62d1d5ae3f08c24fb002d25bc3ea1b1d5b782b8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 10:37:04 +0200 Subject: speciazled diagnostics for i686; more escapes; more opts --- internal/icons.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index 57eb8ad8..af920bcc 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -519,7 +519,7 @@ function _p9k_init_icons() { # Sadly, this is a part of public API. Its use is emphatically discouraged. function print_icon() { - emulate -L zsh + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons local icon_name=$1 local var_name=POWERLEVEL9K_${icon_name} @@ -536,7 +536,7 @@ function print_icon() { # otherwise "print_icon" is used, which takes the users # overrides into account. function get_icon_names() { - emulate -L zsh + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons # Iterate over a ordered list of keys of the icons array for key in ${(@kon)icons}; do -- cgit v1.2.3 From d6401aad69b583bcb51a7862e64e13b530e939cb Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 8 Aug 2019 12:05:58 +0200 Subject: add a space after all os icons --- internal/icons.zsh | 180 ++++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index af920bcc..9b40e6a0 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -33,30 +33,30 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uE26E' #  - WINDOWS_ICON '\uE26F' #  + APPLE_ICON '\uE26E ' #  + WINDOWS_ICON '\uE26F ' #  FREEBSD_ICON '\U1F608 ' # 😈 - ANDROID_ICON '\uE270' #  - LINUX_ICON '\uE271' #  - LINUX_ARCH_ICON '\uE271' #  - LINUX_DEBIAN_ICON '\uE271' #  - LINUX_RASPBIAN_ICON '\uE271' #  - LINUX_UBUNTU_ICON '\uE271' #  - LINUX_CENTOS_ICON '\uE271' #  - LINUX_COREOS_ICON '\uE271' #  - LINUX_ELEMENTARY_ICON '\uE271' #  - LINUX_MINT_ICON '\uE271' #  - LINUX_FEDORA_ICON '\uE271' #  - LINUX_GENTOO_ICON '\uE271' #  - LINUX_MAGEIA_ICON '\uE271' #  - LINUX_NIXOS_ICON '\uE271' #  - LINUX_MANJARO_ICON '\uE271' #  - LINUX_DEVUAN_ICON '\uE271' #  - LINUX_ALPINE_ICON '\uE271' #  - LINUX_AOSC_ICON '\uE271' #  - LINUX_OPENSUSE_ICON '\uE271' #  - LINUX_SABAYON_ICON '\uE271' #  - LINUX_SLACKWARE_ICON '\uE271' #  + ANDROID_ICON '\uE270 ' #  + LINUX_ICON '\uE271 ' #  + LINUX_ARCH_ICON '\uE271 ' #  + LINUX_DEBIAN_ICON '\uE271 ' #  + LINUX_RASPBIAN_ICON '\uE271 ' #  + LINUX_UBUNTU_ICON '\uE271 ' #  + LINUX_CENTOS_ICON '\uE271 ' #  + LINUX_COREOS_ICON '\uE271 ' #  + LINUX_ELEMENTARY_ICON '\uE271 ' #  + LINUX_MINT_ICON '\uE271 ' #  + LINUX_FEDORA_ICON '\uE271 ' #  + LINUX_GENTOO_ICON '\uE271 ' #  + LINUX_MAGEIA_ICON '\uE271 ' #  + LINUX_NIXOS_ICON '\uE271 ' #  + LINUX_MANJARO_ICON '\uE271 ' #  + LINUX_DEVUAN_ICON '\uE271 ' #  + LINUX_ALPINE_ICON '\uE271 ' #  + LINUX_AOSC_ICON '\uE271 ' #  + LINUX_OPENSUSE_ICON '\uE271 ' #  + LINUX_SABAYON_ICON '\uE271 ' #  + LINUX_SLACKWARE_ICON '\uE271 ' #  SUNOS_ICON '\U1F31E ' # 🌞 HOME_ICON '\uE12C' #  HOME_SUB_ICON '\uE18D' #  @@ -134,30 +134,30 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179' #  - WINDOWS_ICON '\uF17A' #  + APPLE_ICON '\uF179 ' #  + WINDOWS_ICON '\uF17A ' #  FREEBSD_ICON '\U1F608 ' # 😈 - ANDROID_ICON '\uE17B' #  - LINUX_ICON '\uF17C' #  - LINUX_ARCH_ICON '\uF17C' #  - LINUX_DEBIAN_ICON '\uF17C' #  - LINUX_RASPBIAN_ICON '\uF17C' #  - LINUX_UBUNTU_ICON '\uF17C' #  - LINUX_CENTOS_ICON '\uF17C' #  - LINUX_COREOS_ICON '\uF17C' #  - LINUX_ELEMENTARY_ICON '\uF17C' #  - LINUX_MINT_ICON '\uF17C' #  - LINUX_FEDORA_ICON '\uF17C' #  - LINUX_GENTOO_ICON '\uF17C' #  - LINUX_MAGEIA_ICON '\uF17C' #  - LINUX_NIXOS_ICON '\uF17C' #  - LINUX_MANJARO_ICON '\uF17C' #  - LINUX_DEVUAN_ICON '\uF17C' #  - LINUX_ALPINE_ICON '\uF17C' #  - LINUX_AOSC_ICON '\uF17C' #  - LINUX_OPENSUSE_ICON '\uF17C' #  - LINUX_SABAYON_ICON '\uF17C' #  - LINUX_SLACKWARE_ICON '\uF17C' #  + ANDROID_ICON '\uE17B ' #  + LINUX_ICON '\uF17C ' #  + LINUX_ARCH_ICON '\uF17C ' #  + LINUX_DEBIAN_ICON '\uF17C ' #  + LINUX_RASPBIAN_ICON '\uF17C ' #  + LINUX_UBUNTU_ICON '\uF17C ' #  + LINUX_CENTOS_ICON '\uF17C ' #  + LINUX_COREOS_ICON '\uF17C ' #  + LINUX_ELEMENTARY_ICON '\uF17C ' #  + LINUX_MINT_ICON '\uF17C ' #  + LINUX_FEDORA_ICON '\uF17C ' #  + LINUX_GENTOO_ICON '\uF17C ' #  + LINUX_MAGEIA_ICON '\uF17C ' #  + LINUX_NIXOS_ICON '\uF17C ' #  + LINUX_MANJARO_ICON '\uF17C ' #  + LINUX_DEVUAN_ICON '\uF17C ' #  + LINUX_ALPINE_ICON '\uF17C ' #  + LINUX_AOSC_ICON '\uF17C ' #  + LINUX_OPENSUSE_ICON '\uF17C ' #  + LINUX_SABAYON_ICON '\uF17C ' #  + LINUX_SLACKWARE_ICON '\uF17C ' #  SUNOS_ICON '\uF185 ' #  HOME_ICON '\uF015' #  HOME_SUB_ICON '\uF07C' #  @@ -238,28 +238,28 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE #  + APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE' ' #  FREEBSD_ICON '\U1F608 ' # 😈 - LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_ARCH_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_DEBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_RASPBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_UBUNTU_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_CENTOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_COREOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_ELEMENTARY_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_MINT_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_FEDORA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_GENTOO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_MAGEIA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_NIXOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_MANJARO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_DEVUAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_ALPINE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_AOSC_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_OPENSUSE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_SABAYON_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_SLACKWARE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  + LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_ARCH_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_DEBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_RASPBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_UBUNTU_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_CENTOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_COREOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_ELEMENTARY_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_MINT_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_FEDORA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_GENTOO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_MAGEIA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_NIXOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_MANJARO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_DEVUAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_ALPINE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_AOSC_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_OPENSUSE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_SABAYON_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_SLACKWARE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  @@ -333,30 +333,30 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179' #  - WINDOWS_ICON '\uF17A' #  + APPLE_ICON '\uF179 ' #  + WINDOWS_ICON '\uF17A ' #  FREEBSD_ICON '\UF30C ' #  - ANDROID_ICON '\uF17B' #  - LINUX_ARCH_ICON '\uF303' #  - LINUX_CENTOS_ICON '\uF304' #  - LINUX_COREOS_ICON '\uF305' #  - LINUX_DEBIAN_ICON '\uF306' #  - LINUX_RASPBIAN_ICON '\uF315' #  - LINUX_ELEMENTARY_ICON '\uF309' #  - LINUX_FEDORA_ICON '\uF30a' #  - LINUX_GENTOO_ICON '\uF30d' #  - LINUX_MAGEIA_ICON '\uF310' #  - LINUX_MINT_ICON '\uF30e' #  - LINUX_NIXOS_ICON '\uF313' #  - LINUX_MANJARO_ICON '\uF312' #  - LINUX_DEVUAN_ICON '\uF307' #  - LINUX_ALPINE_ICON '\uF300' #  - LINUX_AOSC_ICON '\uF301' #  - LINUX_OPENSUSE_ICON '\uF314' #  - LINUX_SABAYON_ICON '\uF317' #  - LINUX_SLACKWARE_ICON '\uF319' #  - LINUX_UBUNTU_ICON '\uF31b' #  - LINUX_ICON '\uF17C' #  + ANDROID_ICON '\uF17B ' #  + LINUX_ARCH_ICON '\uF303 ' #  + LINUX_CENTOS_ICON '\uF304 ' #  + LINUX_COREOS_ICON '\uF305 ' #  + LINUX_DEBIAN_ICON '\uF306 ' #  + LINUX_RASPBIAN_ICON '\uF315 ' #  + LINUX_ELEMENTARY_ICON '\uF309 ' #  + LINUX_FEDORA_ICON '\uF30a ' #  + LINUX_GENTOO_ICON '\uF30d ' #  + LINUX_MAGEIA_ICON '\uF310 ' #  + LINUX_MINT_ICON '\uF30e ' #  + LINUX_NIXOS_ICON '\uF313 ' #  + LINUX_MANJARO_ICON '\uF312 ' #  + LINUX_DEVUAN_ICON '\uF307 ' #  + LINUX_ALPINE_ICON '\uF300 ' #  + LINUX_AOSC_ICON '\uF301 ' #  + LINUX_OPENSUSE_ICON '\uF314 ' #  + LINUX_SABAYON_ICON '\uF317 ' #  + LINUX_SLACKWARE_ICON '\uF319 ' #  + LINUX_UBUNTU_ICON '\uF31b ' #  + LINUX_ICON '\uF17C ' #  SUNOS_ICON '\uF185 ' #  HOME_ICON '\uF015' #  HOME_SUB_ICON '\uF07C' #  -- cgit v1.2.3 From 36174484cc9e9055f5b37bd53b5e7aa1935cdc5e Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 12 Aug 2019 08:40:19 +0200 Subject: slightly better icons --- internal/icons.zsh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index 9b40e6a0..55d1b33e 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -88,16 +88,16 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\uE20E ' # VCS_GIT_GITLAB_ICON '\uE20E ' # VCS_HG_ICON '\uE1C3 ' #  - VCS_SVN_ICON '(svn) ' - RUST_ICON '(rust)' # TODO: try 𝗥. - PYTHON_ICON '\ue63c' #  + VCS_SVN_ICON 'svn' + RUST_ICON 'R' + PYTHON_ICON '\ue63c' #  SWIFT_ICON '' GO_ICON '' PUBLIC_IP_ICON '' LOCK_ICON '\UE138' #  EXECUTION_TIME_ICON '\UE89C' #  - SSH_ICON '(ssh)' - VPN_ICON '(vpn)' + SSH_ICON 'ssh' + VPN_ICON 'vpn' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B' #  DATE_ICON '\uE184' #  @@ -185,7 +185,7 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\uF171 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  - VCS_SVN_ICON '(svn) ' + VCS_SVN_ICON 'svn' RUST_ICON '\uE6A8' #  PYTHON_ICON '\ue63c' #  SWIFT_ICON '' @@ -193,7 +193,7 @@ function _p9k_init_icons() { PUBLIC_IP_ICON '' LOCK_ICON '\UF023' #  EXECUTION_TIME_ICON '\uF253' - SSH_ICON '(ssh)' + SSH_ICON 'ssh' VPN_ICON '\uF023' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B' #  @@ -287,14 +287,14 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  VCS_GIT_GITLAB_ICON '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  VCS_HG_ICON '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  - VCS_SVN_ICON '(svn) ' + VCS_SVN_ICON 'svn' RUST_ICON '\uE6A8' #  - PYTHON_ICON '\U1F40D' # 🐍 + PYTHON_ICON '🐍' SWIFT_ICON '\uE655' #  PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE #  LOCK_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK #  EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  - SSH_ICON '(ssh)' + SSH_ICON 'ssh' VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  @@ -393,7 +393,7 @@ function _p9k_init_icons() { LOCK_ICON '\UF023' #  EXECUTION_TIME_ICON '\uF252' #  SSH_ICON '\uF489' #  - VPN_ICON '(vpn)' + VPN_ICON 'vpn' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B' #  DATE_ICON '\uF073 ' #  @@ -482,7 +482,7 @@ function _p9k_init_icons() { VCS_GIT_GITLAB_ICON '' VCS_HG_ICON '' VCS_SVN_ICON '' - RUST_ICON 'Rust' # TODO: try 𝗥. + RUST_ICON 'R' PYTHON_ICON 'Py' SWIFT_ICON 'Swift' GO_ICON 'Go' -- cgit v1.2.3 From 33e1dd77908c0ae9a12b07b8e88f4ae16a9e53bd Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 17 Aug 2019 09:22:31 +0200 Subject: Try harder when running on a system with incorrectly configured locale. ZSH will still be broken when locale is misconfigured but at least p10k will work so users will look for help elsewhere. Fixes #173. --- config/p10k-classic.zsh | 4 +++- config/p10k-lean.zsh | 4 +++- internal/icons.zsh | 6 ++++++ internal/p10k.zsh | 16 ++++++++-------- internal/wizard.zsh | 4 +++- 5 files changed, 23 insertions(+), 11 deletions(-) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index affca816..7d73e965 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -16,7 +16,9 @@ fi () { emulate -L zsh setopt no_unset - local LC_ALL=C.UTF-8 + if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + fi # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 5b4183ff..2a9f8f2a 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -16,7 +16,9 @@ fi () { emulate -L zsh setopt no_unset - local LC_ALL=C.UTF-8 + if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + fi # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. diff --git a/internal/icons.zsh b/internal/icons.zsh index 55d1b33e..2b47339d 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -3,6 +3,10 @@ typeset -gA icons function _p9k_init_icons() { [[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE ]] && return typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE + typeset -g _p9k_locale=${LC_ALL:-$LANG} + if [[ $_p9k_locale != *.(utf|UTF)(-|)8 ]]; then + _p9k_locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + fi case $POWERLEVEL9K_MODE in 'flat'|'awesome-patched') @@ -521,6 +525,7 @@ function _p9k_init_icons() { function print_icon() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons + local LC_ALL=$_p9k_locale local icon_name=$1 local var_name=POWERLEVEL9K_${icon_name} if [[ -n "${(tP)var_name}" ]]; then @@ -538,6 +543,7 @@ function print_icon() { function get_icon_names() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons + local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array for key in ${(@kon)icons}; do echo -n "POWERLEVEL9K_$key: " diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 5e8d7a27..16f2452c 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -147,7 +147,7 @@ function _p9k_declare() { (( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3 ;; -e) - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale if (( set )); then local v=${(P)2} typeset -g _$2=${(g::)v} @@ -330,7 +330,7 @@ _p9k_get_icon() { if [[ $_p9k_ret == $'\1'* ]]; then _p9k_ret=${_p9k_ret[2,-1]} else - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_ret=${(g::)_p9k_ret} [[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins fi @@ -551,7 +551,7 @@ _p9k_left_prompt_segment() { p+='${${_p9k_e:#00}:+${${_p9k_t[$_p9k_n]/'$ss'/$_p9k_ss}/'$s'/$_p9k_s}' - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != false ]]; then _p9k_param $1 PREFIX '' @@ -752,7 +752,7 @@ _p9k_right_prompt_segment() { p+='${${_p9k_e:#00}:+${_p9k_t[$_p9k_n]/'$w'/$_p9k_w}' - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != true ]]; then _p9k_param $1 PREFIX '' @@ -1091,7 +1091,7 @@ prompt_context() { if [[ -z $content ]]; then local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE if (( $+parameters[$var] )); then - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale content=${(P)var} content=${(g::)content} else @@ -3553,7 +3553,7 @@ _p9k_init_params() { if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then _p9k_declare -e POWERLEVEL9K_BATTERY_STAGES else - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_declare -a POWERLEVEL9K_BATTERY_STAGES -- _POWERLEVEL9K_BATTERY_STAGES=("${(@g::)_POWERLEVEL9K_BATTERY_STAGES}") fi @@ -3816,7 +3816,7 @@ _p9k_build_gap_post() { } _p9k_init_lines() { - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS) local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) @@ -4223,7 +4223,7 @@ _p9k_init() { if _p9k_segment_in_use dir; then if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale local -i i=3 for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 364446b2..b6bbd445 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -5,7 +5,9 @@ setopt noaliases () { setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} -local LC_ALL=C.UTF-8 +if [[ ${LC_ALL:-$LANG} != *.(utf|UTF)(-|)8 ]]; then + local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} +fi typeset -g __p9k_root_dir typeset -gi force=0 -- cgit v1.2.3 From 49063ee757c2339c2a0cde14e886896373cd6a54 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 17 Aug 2019 10:01:06 +0200 Subject: add ranger prompt; see #171 --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 5 +++++ 4 files changed, 24 insertions(+) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 7d73e965..24b73abb 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -58,6 +58,7 @@ fi kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) # =========================[ Line #2 ]========================= newline # public_ip # public IP address @@ -420,6 +421,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=221 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + ####################################[ context: user@host ]#################################### # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 2a9f8f2a..420ef42c 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -58,6 +58,7 @@ fi kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) # =========================[ Line #2 ]========================= newline # public_ip # public IP address @@ -403,6 +404,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=221 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + ####################################[ context: user@host ]#################################### # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 diff --git a/internal/icons.zsh b/internal/icons.zsh index 2b47339d..3693bfb3 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -108,6 +108,7 @@ function _p9k_init_icons() { TIME_ICON '\uE12E' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; 'awesome-fontconfig') @@ -205,6 +206,7 @@ function _p9k_init_icons() { TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; 'awesome-mapped-fontconfig') @@ -306,6 +308,7 @@ function _p9k_init_icons() { TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -404,6 +407,7 @@ function _p9k_init_icons() { TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '\ue73f ' #  + RANGER_ICON '\u2B50' # ⭐ ) ;; *) @@ -501,6 +505,7 @@ function _p9k_init_icons() { TIME_ICON '' JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 16f2452c..3b7897ca 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3034,6 +3034,11 @@ function prompt_nordvpn() { esac } +function prompt_ranger() { + [[ -n $RANGER_LEVEL ]] || return + _p9k_prompt_segment $0 $_p9k_color1 yellow RANGER_ICON 0 '' $RANGER_LEVEL +} + _p9k_preexec() { if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then -- cgit v1.2.3 From 4c12eb7224b053a511a06da0b3efe26f067a4942 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 16:07:59 +0200 Subject: add terraform prompt segment --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 12 ++++++++++++ 4 files changed, 31 insertions(+) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 532a1a08..5eb4f7de 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -56,6 +56,7 @@ fi rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -540,6 +541,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Terraform color. + typeset -g POWERLEVEL9K_TERRAFORM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index f55781a9..8704c59b 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -56,6 +56,7 @@ fi rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -595,6 +596,12 @@ fi # Custom prefix. # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Terraform color. + typeset -g POWERLEVEL9K_TERRAFORM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 diff --git a/internal/icons.zsh b/internal/icons.zsh index 3693bfb3..52155cab 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -109,6 +109,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; 'awesome-fontconfig') @@ -207,6 +208,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; 'awesome-mapped-fontconfig') @@ -309,6 +311,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -408,6 +411,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '\ue73f ' #  RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; *) @@ -506,6 +510,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON 'TF' ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 7ba7b69d..698a45c6 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3039,6 +3039,18 @@ function prompt_ranger() { _p9k_prompt_segment $0 $_p9k_color1 yellow RANGER_ICON 0 '' $RANGER_LEVEL } +function prompt_terraform() { + (( $+commands[terraform] )) || return + local ws=default + if [[ -n $TF_WORKSPACE ]]; then + ws=$TF_WORKSPACE + else + local f=${TF_DATA_DIR:-.terraform}/environment + [[ -r $f ]] && _p9k_read_file $f && ws=$_p9k_ret + fi + [[ $ws == default ]] || _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $ws +} + _p9k_preexec() { if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then -- cgit v1.2.3 From b3010c015648712568bd7a5377eec585bba6fbc7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 16:09:56 +0200 Subject: use hammer and wrench emoji for terraform with all fonts --- internal/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index 52155cab..e93712c4 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -510,7 +510,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ - TERRAFORM_ICON 'TF' + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; esac -- cgit v1.2.3 From e537a0ee628341741f20a7d2d96ea1c4fac74c4a Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 20 Aug 2019 14:56:43 +0200 Subject: better utf-8 handling --- config/p10k-classic.zsh | 3 ++- config/p10k-lean.zsh | 3 ++- internal/icons.zsh | 12 +++++++----- internal/p10k.zsh | 16 ++++++++-------- internal/wizard.zsh | 3 ++- 5 files changed, 21 insertions(+), 16 deletions(-) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 5eb4f7de..6be7c45c 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -16,7 +16,8 @@ fi () { emulate -L zsh setopt no_unset - if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + zmodload zsh/langinfo + if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} fi diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 8704c59b..696d6a4e 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -16,7 +16,8 @@ fi () { emulate -L zsh setopt no_unset - if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + zmodload zsh/langinfo + if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} fi diff --git a/internal/icons.zsh b/internal/icons.zsh index e93712c4..fd2ab1be 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -3,9 +3,11 @@ typeset -gA icons function _p9k_init_icons() { [[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE ]] && return typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE - typeset -g _p9k_locale=${LC_ALL:-$LANG} - if [[ $_p9k_locale != *.(utf|UTF)(-|)8 ]]; then - _p9k_locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + zmodload zsh/langinfo + if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then + typeset -g _p9k_locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + else + typeset -g _p9k_locale= fi case $POWERLEVEL9K_MODE in @@ -535,7 +537,7 @@ function _p9k_init_icons() { function print_icon() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local icon_name=$1 local var_name=POWERLEVEL9K_${icon_name} if [[ -n "${(tP)var_name}" ]]; then @@ -553,7 +555,7 @@ function print_icon() { function get_icon_names() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array for key in ${(@kon)icons}; do echo -n "POWERLEVEL9K_$key: " diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 30499b66..255919a4 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -147,7 +147,7 @@ function _p9k_declare() { (( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3 ;; -e) - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale if (( set )); then local v=${(P)2} typeset -g _$2=${(g::)v} @@ -330,7 +330,7 @@ _p9k_get_icon() { if [[ $_p9k_ret == $'\1'* ]]; then _p9k_ret=${_p9k_ret[2,-1]} else - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_ret=${(g::)_p9k_ret} [[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins fi @@ -551,7 +551,7 @@ _p9k_left_prompt_segment() { p+='${${_p9k_e:#00}:+${${_p9k_t[$_p9k_n]/'$ss'/$_p9k_ss}/'$s'/$_p9k_s}' - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != false ]]; then _p9k_param $1 PREFIX '' @@ -752,7 +752,7 @@ _p9k_right_prompt_segment() { p+='${${_p9k_e:#00}:+${_p9k_t[$_p9k_n]/'$w'/$_p9k_w}' - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != true ]]; then _p9k_param $1 PREFIX '' @@ -1091,7 +1091,7 @@ prompt_context() { if [[ -z $content ]]; then local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE if (( $+parameters[$var] )); then - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale content=${(P)var} content=${(g::)content} else @@ -3570,7 +3570,7 @@ _p9k_init_params() { if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then _p9k_declare -e POWERLEVEL9K_BATTERY_STAGES else - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_declare -a POWERLEVEL9K_BATTERY_STAGES -- _POWERLEVEL9K_BATTERY_STAGES=("${(@g::)_POWERLEVEL9K_BATTERY_STAGES}") fi @@ -3833,7 +3833,7 @@ _p9k_build_gap_post() { } _p9k_init_lines() { - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS) local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) @@ -4250,7 +4250,7 @@ _p9k_init() { if _p9k_segment_in_use dir; then if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local -i i=3 for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index b6bbd445..9941f7ed 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -5,7 +5,8 @@ setopt noaliases () { setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} -if [[ ${LC_ALL:-$LANG} != *.(utf|UTF)(-|)8 ]]; then +zmodload zsh/langinfo +if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} fi -- cgit v1.2.3 From 7d6400774f0a8dc8759044de4396bce7548310d0 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 26 Aug 2019 12:06:06 +0200 Subject: tune trailing whitespace for all icons when using typical non-monospace fonts --- internal/icons.zsh | 226 ++++++++++++++++++++++++++--------------------------- 1 file changed, 113 insertions(+), 113 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index fd2ab1be..425e57c5 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -21,27 +21,27 @@ function _p9k_init_icons() { LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5' # ↵ + CARRIAGE_RETURN_ICON '\u21B5 ' # ↵ ROOT_ICON '\uE801' #  - SUDO_ICON '\uF09C' #  + SUDO_ICON '\uE0A2' #  RUBY_ICON '\uE847 ' #  - AWS_ICON '\uE895' #  - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_ICON '\uE895 ' #  + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\uE82F ' #  - TEST_ICON '\uE891' #  + TEST_ICON '\uE891 ' #  TODO_ICON '\u2611' # ☑ - BATTERY_ICON '\uE894' #  + BATTERY_ICON '\uE894 ' #  DISK_ICON '\uE1AE ' #  OK_ICON '\u2714' # ✔ FAIL_ICON '\u2718' # ✘ SYMFONY_ICON 'SF' - NODE_ICON '\u2B22' # ⬢ + NODE_ICON '\u2B22 ' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ APPLE_ICON '\uE26E ' #  WINDOWS_ICON '\uE26F ' #  - FREEBSD_ICON '\U1F608 ' # 😈 + FREEBSD_ICON '\U1F608' # 😈 ANDROID_ICON '\uE270 ' #  LINUX_ICON '\uE271 ' #  LINUX_ARCH_ICON '\uE271 ' #  @@ -63,19 +63,19 @@ function _p9k_init_icons() { LINUX_OPENSUSE_ICON '\uE271 ' #  LINUX_SABAYON_ICON '\uE271 ' #  LINUX_SLACKWARE_ICON '\uE271 ' #  - SUNOS_ICON '\U1F31E ' # 🌞 - HOME_ICON '\uE12C' #  - HOME_SUB_ICON '\uE18D' #  - FOLDER_ICON '\uE818' #  - NETWORK_ICON '\uE1AD' #  - ETC_ICON '\uE82F' #  + SUNOS_ICON '\U1F31E' # 🌞 + HOME_ICON '\uE12C ' #  + HOME_SUB_ICON '\uE18D ' #  + FOLDER_ICON '\uE818 ' #  + NETWORK_ICON '\uE1AD ' #  + ETC_ICON '\uE82F ' #  LOAD_ICON '\uE190 ' #  - SWAP_ICON '\uE87D' #  + SWAP_ICON '\uE87D ' #  RAM_ICON '\uE1E2 ' #  - SERVER_ICON '\uE895' #  - VCS_UNTRACKED_ICON '\uE16C' #  - VCS_UNSTAGED_ICON '\uE17C' #  - VCS_STAGED_ICON '\uE168' #  + SERVER_ICON '\uE895 ' #  + VCS_UNTRACKED_ICON '\uE16C ' #  + VCS_UNSTAGED_ICON '\uE17C ' #  + VCS_STAGED_ICON '\uE168 ' #  VCS_STASH_ICON '\uE133 ' #  #VCS_INCOMING_CHANGES_ICON '\uE1EB ' #  #VCS_INCOMING_CHANGES_ICON '\uE80D ' #  @@ -96,18 +96,18 @@ function _p9k_init_icons() { VCS_HG_ICON '\uE1C3 ' #  VCS_SVN_ICON 'svn' RUST_ICON 'R' - PYTHON_ICON '\ue63c' #  - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' + PYTHON_ICON '\uE63C ' #  (doesn't always work) + SWIFT_ICON 'Swift' + GO_ICON 'Go' + PUBLIC_IP_ICON 'IP' LOCK_ICON '\UE138' #  - EXECUTION_TIME_ICON '\UE89C' #  + EXECUTION_TIME_ICON '\UE89C ' #  SSH_ICON 'ssh' VPN_ICON 'vpn' - KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B' #  - DATE_ICON '\uE184' #  - TIME_ICON '\uE12E' #  + KUBERNETES_ICON '\U2388 ' # ⎈ + DROPBOX_ICON '\UF16B ' #  (doesn't always work) + DATE_ICON '\uE184 ' #  + TIME_ICON '\uE12E ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ @@ -125,13 +125,13 @@ function _p9k_init_icons() { LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\uF201' #  - SUDO_ICON '\uF09C' #  + ROOT_ICON '\uF201 ' #  + SUDO_ICON '\uF09C ' #  RUBY_ICON '\uF219 ' #  - AWS_ICON '\uF270' #  - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_ICON '\uF270 ' #  + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\uF013 ' #  - TEST_ICON '\uF291' #  + TEST_ICON '\uF291 ' #  TODO_ICON '\u2611' # ☑ BATTERY_ICON '\U1F50B' # 🔋 DISK_ICON '\uF0A0 ' #  @@ -144,8 +144,8 @@ function _p9k_init_icons() { MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ APPLE_ICON '\uF179 ' #  WINDOWS_ICON '\uF17A ' #  - FREEBSD_ICON '\U1F608 ' # 😈 - ANDROID_ICON '\uE17B ' #  + FREEBSD_ICON '\U1F608' # 😈 + ANDROID_ICON '\uE17B ' #  (doesn't always work) LINUX_ICON '\uF17C ' #  LINUX_ARCH_ICON '\uF17C ' #  LINUX_DEBIAN_ICON '\uF17C ' #  @@ -167,23 +167,23 @@ function _p9k_init_icons() { LINUX_SABAYON_ICON '\uF17C ' #  LINUX_SLACKWARE_ICON '\uF17C ' #  SUNOS_ICON '\uF185 ' #  - HOME_ICON '\uF015' #  - HOME_SUB_ICON '\uF07C' #  - FOLDER_ICON '\uF115' #  + HOME_ICON '\uF015 ' #  + HOME_SUB_ICON '\uF07C ' #  + FOLDER_ICON '\uF115 ' #  ETC_ICON '\uF013 ' #  - NETWORK_ICON '\uF09E' #  + NETWORK_ICON '\uF09E ' #  LOAD_ICON '\uF080 ' #  - SWAP_ICON '\uF0E4' #  - RAM_ICON '\uF0E4' #  - SERVER_ICON '\uF233' #  - VCS_UNTRACKED_ICON '\uF059' #  - VCS_UNSTAGED_ICON '\uF06A' #  - VCS_STAGED_ICON '\uF055' #  + SWAP_ICON '\uF0E4 ' #  + RAM_ICON '\uF0E4 ' #  + SERVER_ICON '\uF233 ' #  + VCS_UNTRACKED_ICON '\uF059 ' #  + VCS_UNSTAGED_ICON '\uF06A ' #  + VCS_STAGED_ICON '\uF055 ' #  VCS_STASH_ICON '\uF01C ' #  VCS_INCOMING_CHANGES_ICON '\uF01A ' #  VCS_OUTGOING_CHANGES_ICON '\uF01B ' #  VCS_TAG_ICON '\uF217 ' #  - VCS_BOOKMARK_ICON '\uF27B' #  + VCS_BOOKMARK_ICON '\uF27B ' #  VCS_COMMIT_ICON '\uF221 ' #  VCS_BRANCH_ICON '\uF126 ' #  VCS_REMOTE_BRANCH_ICON '\u2192' # → @@ -194,17 +194,17 @@ function _p9k_init_icons() { VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  VCS_SVN_ICON 'svn' - RUST_ICON '\uE6A8' #  - PYTHON_ICON '\ue63c' #  - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' + RUST_ICON '\uE6A8' #  + PYTHON_ICON '\uE63C ' #  + SWIFT_ICON 'Swift' + GO_ICON 'Go' + PUBLIC_IP_ICON 'IP' LOCK_ICON '\UF023' #  - EXECUTION_TIME_ICON '\uF253' + EXECUTION_TIME_ICON '\uF253 ' #  SSH_ICON 'ssh' VPN_ICON '\uF023' KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B' #  + DROPBOX_ICON '\UF16B ' #  DATE_ICON '\uF073 ' #  TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ @@ -232,24 +232,24 @@ function _p9k_init_icons() { RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ ROOT_ICON '\u'$CODEPOINT_OF_OCTICONS_ZAP #  - SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  + SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK' ' #  RUBY_ICON '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  - AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER' ' #  + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  - TEST_ICON '\u'$CODEPOINT_OF_AWESOME_BUG #  - TODO_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  - BATTERY_ICON '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  + TEST_ICON '\u'$CODEPOINT_OF_AWESOME_BUG' ' #  + TODO_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O' ' #  + BATTERY_ICON '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL' ' #  DISK_ICON '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  - OK_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK #  - FAIL_ICON '\u'$CODEPOINT_OF_AWESOME_TIMES #  + OK_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK' ' #  + FAIL_ICON '\u'$CODEPOINT_OF_AWESOME_TIMES #  SYMFONY_ICON 'SF' NODE_ICON '\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE' ' #  - FREEBSD_ICON '\U1F608 ' # 😈 + FREEBSD_ICON '\U1F608' # 😈 LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  LINUX_ARCH_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  LINUX_DEBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  @@ -271,18 +271,18 @@ function _p9k_init_icons() { LINUX_SABAYON_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  LINUX_SLACKWARE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  - HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  - HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  - FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  + HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME' ' #  + HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN' ' #  + FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O' ' #  ETC_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  - NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  + NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS' ' #  LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  - SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - RAM_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - SERVER_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  - VCS_UNTRACKED_ICON '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  - VCS_UNSTAGED_ICON '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  - VCS_STAGED_ICON '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  + SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD' ' #  + RAM_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD' ' #  + SERVER_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER' ' #  + VCS_UNTRACKED_ICON '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE' ' #  + VCS_UNSTAGED_ICON '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE' ' #  + VCS_STAGED_ICON '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE' ' #  VCS_STASH_ICON '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  VCS_INCOMING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  VCS_OUTGOING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  @@ -290,7 +290,7 @@ function _p9k_init_icons() { VCS_BOOKMARK_ICON '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  VCS_COMMIT_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  VCS_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  - VCS_REMOTE_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  + VCS_REMOTE_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH' ' #  VCS_LOADING_ICON '' VCS_GIT_ICON '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  VCS_GIT_GITHUB_ICON '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  @@ -299,15 +299,15 @@ function _p9k_init_icons() { VCS_HG_ICON '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  VCS_SVN_ICON 'svn' RUST_ICON '\uE6A8' #  - PYTHON_ICON '🐍' - SWIFT_ICON '\uE655' #  - PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE #  + PYTHON_ICON '\U1F40D' # 🐍 + SWIFT_ICON '\uE655 ' #  + PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE' ' #  LOCK_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK #  - EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  + EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END' ' #  SSH_ICON 'ssh' VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  + DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX' ' #  DATE_ICON '\uF073 ' #  TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ @@ -328,36 +328,36 @@ function _p9k_init_icons() { LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\uE614 ' #  - SUDO_ICON '\uF09C' #  + ROOT_ICON '\uE614' #  + SUDO_ICON '\uF09C ' #  RUBY_ICON '\uF219 ' #  - AWS_ICON '\uF270' #  - AWS_EB_ICON '\UF1BD ' #  + AWS_ICON '\uF270 ' #  + AWS_EB_ICON '\UF1BD' #  BACKGROUND_JOBS_ICON '\uF013 ' #  - TEST_ICON '\uF188' #  - TODO_ICON '\uF133' #  + TEST_ICON '\uF188 ' #  + TODO_ICON '\uF133 ' #  BATTERY_ICON '\UF240 ' #  - DISK_ICON '\uF0A0' #  - OK_ICON '\uF00C' #  + DISK_ICON '\uF0A0 ' #  + OK_ICON '\uF00C ' #  FAIL_ICON '\uF00D' #  SYMFONY_ICON '\uE757' #  NODE_ICON '\uE617 ' #  MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179 ' #  + APPLE_ICON '\uF179' #  WINDOWS_ICON '\uF17A ' #  FREEBSD_ICON '\UF30C ' #  - ANDROID_ICON '\uF17B ' #  - LINUX_ARCH_ICON '\uF303 ' #  + ANDROID_ICON '\uF17B' #  + LINUX_ARCH_ICON '\uF303' #  LINUX_CENTOS_ICON '\uF304 ' #  LINUX_COREOS_ICON '\uF305 ' #  - LINUX_DEBIAN_ICON '\uF306 ' #  - LINUX_RASPBIAN_ICON '\uF315 ' #  + LINUX_DEBIAN_ICON '\uF306' #  + LINUX_RASPBIAN_ICON '\uF315' #  LINUX_ELEMENTARY_ICON '\uF309 ' #  LINUX_FEDORA_ICON '\uF30a ' #  LINUX_GENTOO_ICON '\uF30d ' #  - LINUX_MAGEIA_ICON '\uF310 ' #  + LINUX_MAGEIA_ICON '\uF310' #  LINUX_MINT_ICON '\uF30e ' #  LINUX_NIXOS_ICON '\uF313 ' #  LINUX_MANJARO_ICON '\uF312 ' #  @@ -368,20 +368,20 @@ function _p9k_init_icons() { LINUX_SABAYON_ICON '\uF317 ' #  LINUX_SLACKWARE_ICON '\uF319 ' #  LINUX_UBUNTU_ICON '\uF31b ' #  - LINUX_ICON '\uF17C ' #  + LINUX_ICON '\uF17C' #  SUNOS_ICON '\uF185 ' #  - HOME_ICON '\uF015' #  - HOME_SUB_ICON '\uF07C' #  - FOLDER_ICON '\uF115' #  - ETC_ICON '\uF013' #  - NETWORK_ICON '\uF1EB' #  + HOME_ICON '\uF015 ' #  + HOME_SUB_ICON '\uF07C ' #  + FOLDER_ICON '\uF115 ' #  + ETC_ICON '\uF013 ' #  + NETWORK_ICON '\uF1EB ' #  LOAD_ICON '\uF080 ' #  - SWAP_ICON '\uF464' #  - RAM_ICON '\uF0E4' #  - SERVER_ICON '\uF0AE' #  - VCS_UNTRACKED_ICON '\uF059' #  - VCS_UNSTAGED_ICON '\uF06A' #  - VCS_STAGED_ICON '\uF055' #  + SWAP_ICON '\uF464 ' #  + RAM_ICON '\uF0E4 ' #  + SERVER_ICON '\uF0AE ' #  + VCS_UNTRACKED_ICON '\uF059 ' #  + VCS_UNSTAGED_ICON '\uF06A ' #  + VCS_STAGED_ICON '\uF055 ' #  VCS_STASH_ICON '\uF01C ' #  VCS_INCOMING_CHANGES_ICON '\uF01A ' #  VCS_OUTGOING_CHANGES_ICON '\uF01B ' #  @@ -396,22 +396,22 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\uE703 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  - VCS_SVN_ICON '\uE72D ' #  - RUST_ICON '\uE7A8 ' #  + VCS_SVN_ICON '\uE72D' #  + RUST_ICON '\uE7A8' #  PYTHON_ICON '\UE73C ' #  SWIFT_ICON '\uE755' #  GO_ICON '\uE626' #  - PUBLIC_IP_ICON '\UF0AC' #  + PUBLIC_IP_ICON '\UF0AC ' #  LOCK_ICON '\UF023' #  - EXECUTION_TIME_ICON '\uF252' #  - SSH_ICON '\uF489' #  + EXECUTION_TIME_ICON '\uF252 ' #  + SSH_ICON '\uF489 ' #  VPN_ICON 'vpn' KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B' #  + DROPBOX_ICON '\UF16B ' #  DATE_ICON '\uF073 ' #  TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ - LARAVEL_ICON '\ue73f ' #  + LARAVEL_ICON '\ue73f' #  RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) @@ -431,7 +431,7 @@ function _p9k_init_icons() { SUDO_ICON '\uE0A2' #  RUBY_ICON 'Ruby' AWS_ICON 'AWS' - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\u2699' # ⚙ TEST_ICON '' TODO_ICON '\u2611' # ☑ @@ -500,7 +500,7 @@ function _p9k_init_icons() { PYTHON_ICON 'Py' SWIFT_ICON 'Swift' GO_ICON 'Go' - PUBLIC_IP_ICON '' + PUBLIC_IP_ICON 'IP' LOCK_ICON '\UE0A2' EXECUTION_TIME_ICON '' SSH_ICON 'ssh' -- cgit v1.2.3 From 0c627eb31de1b816e98fa17a11ecf675c4e2b366 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 27 Aug 2019 10:57:54 +0200 Subject: add `proxy` prompt segment --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 10 ++++++++++ 4 files changed, 29 insertions(+) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index aab768ef..6864ba47 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -65,6 +65,7 @@ fi # =========================[ Line #2 ]========================= newline # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy # battery # internal battery # example # example user-defined segment (see prompt_example function below) ) @@ -626,6 +627,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################################[ battery: internal battery ]################################# # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index fdc41f30..62ed0bad 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -65,6 +65,7 @@ fi # =========================[ Line #2 ]========================= newline # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy # battery # internal battery # example # example user-defined segment (see prompt_example function below) ) @@ -609,6 +610,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################################[ battery: internal battery ]################################# # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 diff --git a/internal/icons.zsh b/internal/icons.zsh index 425e57c5..c74fe909 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -112,6 +112,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; 'awesome-fontconfig') @@ -211,6 +212,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; 'awesome-mapped-fontconfig') @@ -314,6 +316,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -414,6 +417,7 @@ function _p9k_init_icons() { LARAVEL_ICON '\ue73f' #  RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; *) @@ -513,6 +517,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index cff575b0..5caaea15 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3052,6 +3052,16 @@ function prompt_terraform() { [[ $ws == default ]] || _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $ws } +function prompt_proxy() { + local -U p=( + $all_proxy $http_proxy $https_proxy $ftp_proxy + $ALL_PROXY $HTTP_PROXY $HTTPS_PROXY $FTP_PROXY) + p=(${(@)${(@)${(@)p#*://}##*@}%%/*}) + (( $#p )) || return + (( $#p == 1 )) || p=("") + _p9k_prompt_segment $0 $_p9k_color1 blue PROXY_ICON 0 '' "$p[1]" +} + _p9k_preexec() { if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then -- cgit v1.2.3 From 91b715f18f7f9e9b9bcd921a3387f04e5a3dc7d3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 7 Sep 2019 09:28:45 +0200 Subject: disable or substitute "compatible" icons that cannot be displayed by the stock Menlo on macOS --- config/p10k-classic.zsh | 3 ++- config/p10k-lean.zsh | 2 +- internal/icons.zsh | 2 +- internal/wizard.zsh | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 921c5166..6bcb8645 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -263,7 +263,8 @@ fi # Enable special styling for non-writable directories. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true - # Show this icon when the current directory is not writable. Empty for no icon. + # Show this icon when the current directory is not writable. POWERLEVEL9K_DIR_SHOW_WRITABLE + # above must be set to true for this parameter to have effect. # typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 6f21e5e8..09263d0d 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -245,7 +245,7 @@ fi typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true # Show this icon when the current directory is not writable. POWERLEVEL9K_DIR_SHOW_WRITABLE # above must be set to true for this parameter to have effect. - # POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' diff --git a/internal/icons.zsh b/internal/icons.zsh index c74fe909..cacbb535 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -432,7 +432,7 @@ function _p9k_init_icons() { RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ ROOT_ICON '\u26A1' # ⚡ - SUDO_ICON '\uE0A2' #  + SUDO_ICON '' RUBY_ICON 'Ruby' AWS_ICON 'AWS' AWS_EB_ICON '\U1F331' # 🌱 diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 9e5d4b8f..d8e251ce 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1217,8 +1217,10 @@ function generate_config() { fi if [[ $POWERLEVEL9K_MODE == compatible ]]; then - # Many fonts don't have the gear icon. + # Many fonts don't have the gear or the lock icon. sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'⇶'" + uncomment 'typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION' + sub DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION "'∅'" fi if [[ $POWERLEVEL9K_MODE == (awesome-patched|awesome-fontconfig) && $cap_python == 0 ]]; then -- cgit v1.2.3 From 3674e69b4329fba47945e0fd2beb065ea4cd1cd9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 12 Sep 2019 10:58:37 +0200 Subject: stop setting prompt_cr and prompt_sp --- internal/icons.zsh | 4 ++-- internal/p10k.zsh | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index cacbb535..e0102fed 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -540,7 +540,7 @@ function _p9k_init_icons() { # Sadly, this is a part of public API. Its use is emphatically discouraged. function print_icon() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local icon_name=$1 @@ -558,7 +558,7 @@ function print_icon() { # otherwise "print_icon" is used, which takes the users # overrides into account. function get_icon_names() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array diff --git a/internal/p10k.zsh b/internal/p10k.zsh index d2f17f08..6a080586 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -89,7 +89,7 @@ typeset -grA __p9k_colors=( # # Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors. function getColorCode() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if (( ARGC == 1 )); then case $1 in foreground) @@ -170,7 +170,7 @@ function _p9k_declare() { # _p9k_prompt_length '%F{red}abc' => 3 # _p9k_prompt_length $'%{a\b%Gb%}' => 1 function _p9k_prompt_length() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local COLUMNS=1024 local -i x y=$#1 m if (( y )); then @@ -2599,7 +2599,7 @@ function _p9k_vcs_render() { } function _p9k_vcs_resume() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $VCS_STATUS_RESULT == ok-async ]]; then local latency=$((EPOCHREALTIME - _p9k_gitstatus_start_time)) @@ -3183,7 +3183,7 @@ function _p9k_update_prompt() { } powerlevel9k_refresh_prompt_inplace() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( __p9k_enabled )) || return _p9k_refresh_reason=precmd _p9k_set_prompt @@ -3196,7 +3196,7 @@ typeset -gi __p9k_new_status typeset -ga __p9k_new_pipestatus _p9k_save_status() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -i pipe if (( !$+_p9k_line_finished )); then : # SIGINT @@ -3296,7 +3296,7 @@ _p9k_precmd() { } function _p9k_zle_keymap_select() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} zle && zle .reset-prompt && zle -R } @@ -3328,7 +3328,7 @@ _p9k_deinit_async_pump() { } function _p9k_on_async_message() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( ARGC == 1 )) || return local msg='' IFS='' while read -r -t -u $1 msg; do @@ -3341,11 +3341,11 @@ function _p9k_on_async_message() { } function _p9k_async_pump() { - emulate -L zsh || return - setopt no_aliases no_hist_expand extended_glob || return - setopt no_prompt_bang prompt_{cr,percent,subst,sp} || return - zmodload zsh/system zsh/datetime || return - echo $$ || return + emulate -L zsh || return + setopt no_aliases no_hist_expand extended_glob || return + setopt no_prompt_bang prompt_{percent,subst} || return + zmodload zsh/system zsh/datetime || return + echo $$ || return local ip last_ip local -F next_ip_time @@ -3404,7 +3404,7 @@ function _p9k_async_pump() { } function _p9k_kill_async_pump() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $ZSH_SUBSHELL == $_p9k_async_pump_subshell && $$ == $_p9k_async_pump_shell_pid ]]; then _p9k_deinit_async_pump fi @@ -3848,7 +3848,7 @@ function _p9k_zle_line_finish() { (( __p9k_enabled )) || return _p9k_line_finished= if (( _p9k_reset_on_line_finish )); then - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} zle && zle .reset-prompt && zle -R fi } @@ -3858,7 +3858,7 @@ function _p9k_zle_line_pre_redraw() { [[ ${KEYMAP:-} == vicmd ]] || return 0 local region=${${REGION_ACTIVE:-0}/2/1} [[ $region != $_p9k_region_active ]] || return 0 - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_region_active=$region zle && zle .reset-prompt && zle -R } @@ -4129,7 +4129,7 @@ _p9k_init_ssh() { } _p9k_must_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -a param_keys=( ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig @@ -4148,7 +4148,7 @@ function _p9k_set_os() { } _p9k_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons _p9k_init_vars @@ -4377,7 +4377,7 @@ typeset -gi __p9k_enabled=0 typeset -gi __p9k_configured=0 prompt_powerlevel9k_setup() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} prompt_powerlevel9k_teardown __p9k_enabled=1 add-zsh-hook preexec _p9k_preexec @@ -4385,7 +4385,7 @@ prompt_powerlevel9k_setup() { } prompt_powerlevel9k_teardown() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*' add-zsh-hook -D preexec '(_p9k_|powerlevel9k_)*' PROMPT='%m%# ' -- cgit v1.2.3 From a7e3a70069b138cbfdd58cca1f97409897e0a726 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 19 Sep 2019 14:11:44 +0200 Subject: better PROXY_ICON --- internal/icons.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index e0102fed..fd94b456 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -112,7 +112,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; 'awesome-fontconfig') @@ -212,7 +212,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; 'awesome-mapped-fontconfig') @@ -316,7 +316,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -417,7 +417,7 @@ function _p9k_init_icons() { LARAVEL_ICON '\ue73f' #  RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; *) @@ -517,7 +517,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; esac -- cgit v1.2.3 From 4563f744dd377aca6ae68b5549a9ba2c078346a3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 19 Sep 2019 14:34:14 +0200 Subject: use lock as vpn icon where lock is available --- internal/icons.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index fd94b456..351a5b12 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -103,7 +103,7 @@ function _p9k_init_icons() { LOCK_ICON '\UE138' #  EXECUTION_TIME_ICON '\UE89C ' #  SSH_ICON 'ssh' - VPN_ICON 'vpn' + VPN_ICON '\UE138' KUBERNETES_ICON '\U2388 ' # ⎈ DROPBOX_ICON '\UF16B ' #  (doesn't always work) DATE_ICON '\uE184 ' #  @@ -408,7 +408,7 @@ function _p9k_init_icons() { LOCK_ICON '\UF023' #  EXECUTION_TIME_ICON '\uF252 ' #  SSH_ICON '\uF489 ' #  - VPN_ICON 'vpn' + VPN_ICON '\UF023' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B ' #  DATE_ICON '\uF073 ' #  -- cgit v1.2.3 From 0067e0d4a1148593e3d74640579e555439ee9426 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 11:22:14 +0200 Subject: survive emulate sh; fixes #226 --- config/p10k-classic.zsh | 27 +++--- config/p10k-lean.zsh | 23 +++--- internal/configure.zsh | 5 +- internal/icons.zsh | 6 +- internal/p10k.zsh | 215 +++++++++++++++++++++++++++++++++--------------- internal/wizard.zsh | 2 +- powerlevel9k.zsh-theme | 4 +- 7 files changed, 181 insertions(+), 101 deletions(-) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 1480976f..2041d379 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -5,13 +5,12 @@ # # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done -if [[ -o 'aliases' ]]; then - # Temporarily disable aliases. - 'builtin' 'unsetopt' 'aliases' - local p9k_classic_restore_aliases=1 -else - local p9k_classic_restore_aliases=0 -fi +# Temporarily change options. +local p10k_config_opts=() +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' () { emulate -L zsh @@ -329,16 +328,16 @@ fi vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} # If local branch name is at most 32 characters long, show it in full. # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. - vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. - vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' + vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}' # '@72f5c8a' if not on a branch. - vcs+=':-%248F@%76F${VCS_STATUS_COMMIT[1,8]}}' + vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}' # ':master' if the tracking branch name differs from local branch. - vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%248F:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' + vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' # '#tag' if on a tag. - vcs+='${VCS_STATUS_TAG:+%248F#%76F${VCS_STATUS_TAG//\%/%%}}' + vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}' # ⇣42 if behind the remote. vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}' # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. @@ -745,5 +744,5 @@ fi typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' } -(( ! p9k_classic_restore_aliases )) || setopt aliases -'builtin' 'unset' 'p9k_classic_restore_aliases' +setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index e2d7b863..7ec288d4 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -5,13 +5,12 @@ # # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done -if [[ -o 'aliases' ]]; then - # Temporarily disable aliases. - 'builtin' 'unsetopt' 'aliases' - local p10k_lean_restore_aliases=1 -else - local p10k_lean_restore_aliases=0 -fi +# Temporarily change options. +local p10k_config_opts=() +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' () { emulate -L zsh @@ -309,12 +308,12 @@ fi vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} # If local branch name is at most 32 characters long, show it in full. # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. - vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. - vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' + vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}' # '@72f5c8a' if not on a branch. - vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' + vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}' # ':master' if the tracking branch name differs from local branch. vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' # '#tag' if on a tag. @@ -724,5 +723,5 @@ fi typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' } -(( ! p10k_lean_restore_aliases )) || setopt aliases -'builtin' 'unset' 'p10k_lean_restore_aliases' +setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/internal/configure.zsh b/internal/configure.zsh index ae24be34..202978f6 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -11,7 +11,7 @@ typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$ function _p9k_can_configure() { emulate -L zsh - setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} + setopt extended_glob no_prompt_{bang,subst} prompt_percent [[ $1 == '-q' ]] && local -i q=1 || local -i q=0 function $0_error() { (( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2 @@ -59,7 +59,8 @@ function _p9k_can_configure() { } function p9k_configure() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh + setopt no_hist_expand extended_glob ( local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}") if (( $#p )); then diff --git a/internal/icons.zsh b/internal/icons.zsh index 351a5b12..918b0565 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -540,7 +540,8 @@ function _p9k_init_icons() { # Sadly, this is a part of public API. Its use is emphatically discouraged. function print_icon() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local icon_name=$1 @@ -558,7 +559,8 @@ function print_icon() { # otherwise "print_icon" is used, which takes the users # overrides into account. function get_icon_names() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 839f3cf5..eeef6a90 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -89,7 +89,8 @@ typeset -grA __p9k_colors=( # # Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors. function getColorCode() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if (( ARGC == 1 )); then case $1 in foreground) @@ -170,7 +171,6 @@ function _p9k_declare() { # _p9k_prompt_length '%F{red}abc' => 3 # _p9k_prompt_length $'%{a\b%Gb%}' => 1 function _p9k_prompt_length() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local COLUMNS=1024 local -i x y=$#1 m if (( y )); then @@ -456,7 +456,7 @@ _p9k_left_prompt_segment() { # 4 # fi - local t=$#_p9k_t + local t=$(($#_p9k_t - __p9k_ksh_arrays)) _p9k_t+=$start_sep$style$left_space # 1 _p9k_t+=$style # 2 if [[ -n $fg_color && $fg_color == $bg_color ]]; then @@ -477,10 +477,15 @@ _p9k_left_prompt_segment() { local p= p+="\${_p9k_n::=}" - p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 - p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 - p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x(\$_p9k_bg|\${_p9k_bg:-0})}:+$((t+3))}}" # 3 - p+="\${_p9k_n:=$((t+4))}" # 4 + p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 + p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 + if (( __p9k_sh_glob )); then + p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x\$_p9k_bg}:+$((t+3))}}" # 3 + p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x\$${_p9k_bg:-0}}:+$((t+3))}}" # 3 + else + p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x(\$_p9k_bg|\${_p9k_bg:-0})}:+$((t+3))}}" # 3 + fi + p+="\${_p9k_n:=$((t+4))}" # 4 _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"} @@ -666,7 +671,7 @@ _p9k_right_prompt_segment() { # 4 # fi - local t=$#_p9k_t + local t=$(($#_p9k_t - __p9k_ksh_arrays)) _p9k_t+=$start_sep$style$left_space # 1 _p9k_t+=$w$style # 2 _p9k_t+=$w$subsep$style$left_space # 3 @@ -678,10 +683,15 @@ _p9k_right_prompt_segment() { local p= p+="\${_p9k_n::=}" - p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 - p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 - p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x(${(b)bg_color}|${(b)bg_color:-0})}:+$((t+3))}}" # 3 - p+="\${_p9k_n:=$((t+4))}" # 4 + p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 + p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 + if (( __p9k_sh_glob )); then + p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x${(b)bg_color}}:+$((t+3))}}" # 3 + p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x${(b)bg_color:-0}}:+$((t+3))}}" # 3 + else + p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x(${(b)bg_color}|${(b)bg_color:-0})}:+$((t+3))}}" # 3 + fi + p+="\${_p9k_n:=$((t+4))}" # 4 _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"} @@ -2030,24 +2040,46 @@ prompt_status() { } prompt_prompt_char() { - if (( _p9k_status )); then - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' - _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + if (( __p9k_sh_glob )); then + if (( _p9k_status )); then + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' '❯' + _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶' + else + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' '❯' + fi + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' 'Ⅴ' else - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' '❯' + _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶' + else + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' '❯' + fi + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' 'Ⅴ' fi - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' - _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + if (( _p9k_status )); then + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' + _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + else + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + fi + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' + _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + else + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + fi + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi } @@ -2615,7 +2647,8 @@ function _p9k_vcs_render() { } function _p9k_vcs_resume() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $VCS_STATUS_RESULT == ok-async ]]; then local latency=$((EPOCHREALTIME - _p9k_gitstatus_start_time)) @@ -2726,22 +2759,42 @@ prompt_vcs() { ################################################################ # Vi Mode: show editing mode (NORMAL|INSERT|VISUAL) prompt_vi_mode() { - if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + if (( __p9k_sh_glob )); then + if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi + _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" + else + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi + fi + + if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" + else + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${$((! ${#${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}})):#0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" fi - _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" else - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi + _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" + else + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi fi - fi - if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" - else - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" + else + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + fi fi } @@ -3203,11 +3256,12 @@ function _p9k_update_prompt() { _p9k_refresh_reason=$1 _p9k_set_prompt _p9k_refresh_reason='' - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt } powerlevel9k_refresh_prompt_inplace() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( __p9k_enabled )) || return _p9k_refresh_reason=precmd _p9k_set_prompt @@ -3216,11 +3270,12 @@ powerlevel9k_refresh_prompt_inplace() { p9k_refresh_prompt_inplace() { powerlevel9k_refresh_prompt_inplace } +typeset -gi __p9k_sh_glob +typeset -gi __p9k_ksh_arrays typeset -gi __p9k_new_status typeset -ga __p9k_new_pipestatus _p9k_save_status() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -i pipe if (( !$+_p9k_line_finished )); then : # SIGINT @@ -3264,9 +3319,11 @@ _p9k_save_status() { fi } -_p9k_precmd() { - __p9k_new_status=$? - __p9k_new_pipestatus=($pipestatus) +_p9k_precmd_impl() { + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + + (( __p9k_enabled )) || return if ! zle; then print -rn "${_p9k_prompt_newline:-}" @@ -3317,23 +3374,38 @@ _p9k_precmd() { _p9k_zle_state=insert fi + _p9k_refresh_reason=precmd + _p9k_set_prompt + _p9k_refresh_reason='' +} + +_p9k_precmd() { + __p9k_new_status=$? + __p9k_new_pipestatus=($pipestatus) + [[ -o ksh_arrays ]] && __p9k_ksh_arrays=1 || __p9k_ksh_arrays=0 + [[ -o sh_glob ]] && __p9k_sh_glob=1 || __p9k_sh_glob=0 + unsetopt localoptions prompt_opts=(percent subst) [[ ! -o prompt_sp ]] || prompt_opts+=sp [[ ! -o prompt_cr ]] || prompt_opts+=cr - setopt nopromptbang prompt{percent,subst} + setopt nopromptbang prompt_percent prompt_subst - powerlevel9k_refresh_prompt_inplace + _p9k_precmd_impl } -function _p9k_zle_keymap_select() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} +function _p9k_reset_prompt() { + (( __p9k_ksh_arrays )) && setopt ksh_arrays + (( __p9k_sh_glob )) && setopt sh_glob zle && zle .reset-prompt && zle -R } +function _p9k_zle_keymap_select() { + _p9k_reset_prompt +} + function _p9k_zle_state_changed() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt } _p9k_deinit_async_pump() { @@ -3364,7 +3436,8 @@ _p9k_deinit_async_pump() { } function _p9k_on_async_message() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( ARGC == 1 )) || return local msg='' IFS='' while read -r -t -u $1 msg; do @@ -3373,7 +3446,7 @@ function _p9k_on_async_message() { msg= done _p9k_async_pump_line+=$msg - [[ $__p9k_enabled == 1 && $1 == $_p9k_async_pump_fd ]] && zle && zle .reset-prompt && zle -R + [[ $__p9k_enabled == 1 && $1 == $_p9k_async_pump_fd ]] && _p9k_reset_prompt } function _p9k_async_pump() { @@ -3440,7 +3513,8 @@ function _p9k_async_pump() { } function _p9k_kill_async_pump() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $ZSH_SUBSHELL == $_p9k_async_pump_subshell && $$ == $_p9k_async_pump_shell_pid ]]; then _p9k_deinit_async_pump fi @@ -3880,7 +3954,9 @@ _p9k_wrap_zle_widget() { local wrapper=_p9k_wrapper_$widget_$hook eval "function ${(q)wrapper}() { - ${(q)hook} \"\$@\" + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + (( __p9k_enabled )) && ${(q)hook} \"\$@\" (( \$+widgets[${(q)orig}] )) && zle ${(q)orig} -- \"\$@\" }" @@ -3888,22 +3964,18 @@ _p9k_wrap_zle_widget() { } function _p9k_zle_line_finish() { - (( __p9k_enabled )) || return _p9k_line_finished= if (( _p9k_reset_on_line_finish )); then - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt fi } function _p9k_zle_line_pre_redraw() { - (( __p9k_enabled )) || return [[ ${KEYMAP:-} == vicmd ]] || return 0 local region=${${REGION_ACTIVE:-0}/2/1} [[ $region != $_p9k_region_active ]] || return 0 - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_region_active=$region - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt } prompt__p9k_internal_nothing() { @@ -3938,7 +4010,11 @@ _p9k_build_gap_post() { _p9k_ret+='${:-"'$exp'"}' style=1 fi - _p9k_ret+=$'$_p9k_rprompt$_p9k_t[$((1+!_p9k_ind))]}:-\n}' + if (( __p9k_ksh_arrays )); then + _p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((!_p9k_ind))]}}:-\n}' + else + _p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((1+!_p9k_ind))]}}:-\n}' + fi [[ -n $style ]] && _p9k_ret+='%b%k%f' } @@ -4128,7 +4204,11 @@ _p9k_init_prompt() { [[ $ruler_char == '.' ]] && local sep=',' || local sep='.' local ruler_len='${$((_p9k_clm-_p9k_ind))/#-*/0}' _p9k_prompt_prefix_left+="\${(pl$sep$ruler_len$sep$sep${(q)ruler_char}$sep)}%k%f" - _p9k_prompt_prefix_left+='$_p9k_t[$((1+!_p9k_ind))]' + if (( __p9k_ksh_arrays )); then + _p9k_prompt_prefix_left+='${_p9k_t[$((!_p9k_ind))]}' + else + _p9k_prompt_prefix_left+='${_p9k_t[$((1+!_p9k_ind))]}' + fi else print -rP -- "%F{red}WARNING!%f %BPOWERLEVEL9K_RULER_CHAR%b is not one character long. Ruler won't be rendered." print -rP -- "Either change the value of %BPOWERLEVEL9K_RULER_CHAR%b or set %BPOWERLEVEL9K_SHOW_RULER=false%b to" @@ -4179,12 +4259,11 @@ _p9k_init_ssh() { } _p9k_must_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -a param_keys=( ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" - IFS=$'\2' eval "param_sig=x\"$param_sig\"" + IFS=$'\2' eval "param_sig=$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" [[ -o transient_rprompt ]] && param_sig+=t [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4198,8 +4277,6 @@ function _p9k_set_os() { } _p9k_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - _p9k_init_icons _p9k_init_vars _p9k_init_params @@ -4433,7 +4510,8 @@ typeset -gi __p9k_enabled=0 typeset -gi __p9k_configured=0 prompt_powerlevel9k_setup() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} prompt_powerlevel9k_teardown __p9k_enabled=1 add-zsh-hook preexec _p9k_preexec @@ -4441,7 +4519,8 @@ prompt_powerlevel9k_setup() { } prompt_powerlevel9k_teardown() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*' add-zsh-hook -D preexec '(_p9k_|powerlevel9k_)*' PROMPT='%m%# ' diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 7210a318..f42e6cd3 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -4,7 +4,7 @@ emulate -L zsh setopt noaliases () { -setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} typeset_silent +setopt extended_glob no_prompt_{bang,subst} prompt_percent typeset_silent zmodload zsh/langinfo if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6e4969d7..f44e6870 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,11 +17,11 @@ else local __p9k_restore_aliases=0 fi -typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} +typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" () { emulate -L zsh - setopt no_hist_expand extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} + setopt no_hist_expand extended_glob no_prompt_bang no_prompt_subst prompt_percent if (( $+__p9k_sourced )); then prompt_powerlevel9k_setup return -- cgit v1.2.3 From 4a4f7e1eef960881661276ab382f1bc5a5bb46a3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 24 Sep 2019 10:17:54 +0200 Subject: new prompt segment: dotnet_version To enable this segment: 1. Run `p10k configure`. 2. Open `~/.p10k.zsh` and search for `dotnet_version`. 3. Uncomment the first occurrence. Fixes #233. --- config/p10k-classic.zsh | 9 +++++++++ config/p10k-lean.zsh | 9 +++++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 21 +++++++++++++++++++-- 4 files changed, 42 insertions(+), 2 deletions(-) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 376879d9..da478513 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -53,6 +53,7 @@ # node_version # node.js version # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) @@ -575,6 +576,14 @@ # Custom icon. # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index d6a7af92..fa69892d 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -53,6 +53,7 @@ # node_version # node.js version # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) @@ -554,6 +555,14 @@ # Custom icon. # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 diff --git a/internal/icons.zsh b/internal/icons.zsh index 918b0565..36e76fac 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -113,6 +113,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; 'awesome-fontconfig') @@ -213,6 +214,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; 'awesome-mapped-fontconfig') @@ -317,6 +319,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -418,6 +421,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '\uE77F' #  ) ;; *) @@ -518,6 +522,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index bf016b1e..e6a75c15 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1627,7 +1627,7 @@ prompt_load() { } function _p9k_cached_cmd_stdout() { - local cmd=$commands[$1] + local cmd=${commands[$1]:A} [[ -n $cmd ]] || return shift local -H stat @@ -1642,7 +1642,7 @@ function _p9k_cached_cmd_stdout() { } function _p9k_cached_cmd_stdout_stderr() { - local cmd=$commands[$1] + local cmd=${commands[$1]:A} [[ -n $cmd ]] || return shift local -H stat @@ -1844,6 +1844,22 @@ prompt_nodenv() { _p9k_prompt_segment "$0" "black" "green" 'NODE_ICON' 0 '' "${v//\%/%%}" } +prompt_dotnet_version() { + (( $+commands[dotnet] )) || return + + if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then + local dir=$_p9k_pwd + while true; do + [[ $dir == / ]] && return + [[ -n $dir/(project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln)(#qN^/) ]] && break + dir=${dir:h} + done + fi + + _p9k_cached_cmd_stdout dotnet --version || return + _p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k_ret" +} + ################################################################ # Segment to print a little OS icon prompt_os_icon() { @@ -3821,6 +3837,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 + _p9k_declare -b POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_GO_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 -- cgit v1.2.3 From 0cb680edd1989e6a643b320ab28e2618bd8d068d Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 14:21:58 +0200 Subject: fix bugs in startup speedup and make it yet faster --- internal/icons.zsh | 4 +- internal/p10k.zsh | 117 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 82 insertions(+), 39 deletions(-) (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh index 36e76fac..718e1663 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -544,7 +544,7 @@ function _p9k_init_icons() { } # Sadly, this is a part of public API. Its use is emphatically discouraged. -function print_icon() { +function _p9k_print_icon() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons @@ -563,7 +563,7 @@ function print_icon() { # * $1 string - If "original", then the original icons are printed, # otherwise "print_icon" is used, which takes the users # overrides into account. -function get_icon_names() { +function _p9k_get_icon_names() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 20685b32..27efcca8 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -27,7 +27,6 @@ if ! autoload -Uz is-at-least || ! is-at-least 5.1; then return 1 fi -source "${__p9k_root_dir}/internal/icons.zsh" source "${__p9k_root_dir}/internal/configure.zsh" # For compatibility with Powerlevel9k. It's not recommended to use mnemonic color @@ -115,6 +114,26 @@ function getColorCode() { return 1 } +# Sadly, this is a part of public API. Its use is emphatically discouraged. +function print_icon() { + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} no_aliases + (( $+functions[_p9k_print_icon] )) || source "${__p9k_root_dir}/internal/icons.zsh" + _p9k_print_icon "$@" +} + +# Prints a list of configured icons. +# +# * $1 string - If "original", then the original icons are printed, +# otherwise "print_icon" is used, which takes the users +# overrides into account. +function get_icon_names() { + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} no_aliases + (( $+functions[_p9k_get_icon_names] )) || source "${__p9k_root_dir}/internal/icons.zsh" + _p9k_get_icon_names "$@" +} + # _p9k_declare [default]... function _p9k_declare() { local -i set=$+parameters[$2] @@ -2488,7 +2507,7 @@ function _p9k_vcs_icon() { function _p9k_vcs_render() { local state - if (( $+_p9k_next_vcs_dir )); then + if (( $+_p9k_gitstatus_next_dir )); then if _p9k_vcs_status_for_dir ${${GIT_DIR:A}:-$_p9k_pwd_a}; then _p9k_vcs_status_restore $_p9k_ret state=LOADING @@ -2678,23 +2697,23 @@ function _p9k_vcs_resume() { _p9k_vcs_status_save fi - if [[ -z $_p9k_next_vcs_dir ]]; then - unset _p9k_next_vcs_dir + if [[ -z $_p9k_gitstatus_next_dir ]]; then + unset _p9k_gitstatus_next_dir case $VCS_STATUS_RESULT in norepo-async) (( $1 )) && _p9k_vcs_status_purge ${${GIT_DIR:A}:-$_p9k_pwd_a};; - ok-async) (( $1 )) || _p9k_next_vcs_dir=${${GIT_DIR:A}:-$_p9k_pwd_a};; + ok-async) (( $1 )) || _p9k_gitstatus_next_dir=${${GIT_DIR:A}:-$_p9k_pwd_a};; esac fi - if [[ -n $_p9k_next_vcs_dir ]]; then - if ! gitstatus_query -d $_p9k_next_vcs_dir -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then - unset _p9k_next_vcs_dir + if [[ -n $_p9k_gitstatus_next_dir ]]; then + if ! gitstatus_query -d $_p9k_gitstatus_next_dir -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then + unset _p9k_gitstatus_next_dir unset VCS_STATUS_RESULT else case $VCS_STATUS_RESULT in - tout) _p9k_next_vcs_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; - norepo-sync) _p9k_vcs_status_purge $_p9k_next_vcs_dir; unset _p9k_next_vcs_dir;; - ok-sync) _p9k_vcs_status_save; unset _p9k_next_vcs_dir;; + tout) _p9k_gitstatus_next_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; + norepo-sync) _p9k_vcs_status_purge $_p9k_gitstatus_next_dir; unset _p9k_gitstatus_next_dir;; + ok-sync) _p9k_vcs_status_save; unset _p9k_gitstatus_next_dir;; esac fi fi @@ -2704,15 +2723,15 @@ function _p9k_vcs_resume() { function _p9k_vcs_gitstatus() { if [[ $_p9k_refresh_reason == precmd ]]; then - if (( $+_p9k_next_vcs_dir )); then - _p9k_next_vcs_dir=${${GIT_DIR:A}:-$_p9k_pwd_a} + if (( $+_p9k_gitstatus_next_dir )); then + _p9k_gitstatus_next_dir=${${GIT_DIR:A}:-$_p9k_pwd_a} else local dir=${${GIT_DIR:A}:-$_p9k_pwd_a} local -F timeout=_POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS if ! _p9k_vcs_status_for_dir $dir; then gitstatus_query -d $dir -t $timeout -p -c '_p9k_vcs_resume 0' POWERLEVEL9K || return 1 case $VCS_STATUS_RESULT in - tout) _p9k_next_vcs_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME; return 0;; + tout) _p9k_gitstatus_next_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME; return 0;; norepo-sync) return 0;; ok-sync) _p9k_vcs_status_save;; esac @@ -2726,12 +2745,13 @@ function _p9k_vcs_gitstatus() { done dir=${${GIT_DIR:A}:-$_p9k_pwd_a} fi + (( _p9k_prompt_idx == 1 )) && timeout=0 if ! gitstatus_query -d $dir -t $timeout -c '_p9k_vcs_resume 1' POWERLEVEL9K; then unset VCS_STATUS_RESULT return 1 fi case $VCS_STATUS_RESULT in - tout) _p9k_next_vcs_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; + tout) _p9k_gitstatus_next_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; norepo-sync) _p9k_vcs_status_purge $dir;; ok-sync) _p9k_vcs_status_save;; esac @@ -3338,27 +3358,38 @@ _p9k_save_status() { } function _p9k_dump_state() { - local dir=${XDG_CACHE_HOME:-$HOME/.cache} + is-at-least 5.3 || return + local dir=${_p9k_state_file:h} [[ -d $dir ]] || mkdir -pm 0700 $dir || return [[ -w $dir && -z $dir(#qNR) ]] || return - local tmp=$dir/p10k-state-$USER.zsh.$$-$EPOCHREALTIME-$RANDOM + local tmp=$_p9k_state_file.$$-$EPOCHREALTIME-$RANDOM local -i fd sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { - print -r -- "# $_p9k_param_sig" >&$fd || return - typeset -pm '(_POWERLEVEL9K_|_p9k_)*~(_p9k_async_pump*)' >&$fd || return + print -r -- $_p9k_param_sig >&$fd || return + local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' + local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx' + typeset -pm "($include)~($exclude)" >&$fd || return } always { exec {fd}>&- } - zf_mv -f $tmp $dir/p10k-state-$USER.zsh + zf_mv -f $tmp $_p9k_state_file } function _p9k_restore_state() { - local file=${XDG_CACHE_HOME:-$HOME/.cache}/p10k-state-$USER.zsh - [[ -r $file && -z $file(#qNW) ]] || return - local content && content="$(<$file)" - [[ $content == '# '$_p9k_param_sig$'\n'* ]] || return - eval $content + [[ -z $_p9k_state_file(#qNW) ]] || return + local tmp=$_p9k_state_file.$$-$EPOCHREALTIME-$RANDOM + zf_mv -f $_p9k_state_file $tmp 2>/dev/null || return + { + [[ -r $tmp ]] || return + local sig + IFS='' read -r sig <$tmp || return + [[ $sig == $_p9k_param_sig ]] || return + source $tmp || return + _p9k_state_restored=1 + } always { + zf_mv -f $tmp $_p9k_state_file 2>/dev/null + } } _p9k_precmd_impl() { @@ -3367,8 +3398,6 @@ _p9k_precmd_impl() { (( __p9k_enabled )) || return - local -i init=0 - if ! zle || [[ -z $_p9k_param_sig ]]; then if zle; then __p9k_new_status=0 @@ -3404,12 +3433,10 @@ _p9k_precmd_impl() { fi fi _p9k_init - local -i init=1 fi - _p9k_timer_end=EPOCHREALTIME if (( _p9k_timer_start )); then - typeset -gF P9K_COMMAND_DURATION_SECONDS=$((_p9k_timer_end - _p9k_timer_start)) + typeset -gF P9K_COMMAND_DURATION_SECONDS=$((EPOCHREALTIME - _p9k_timer_start)) else unset P9K_COMMAND_DURATION_SECONDS fi @@ -3422,13 +3449,19 @@ _p9k_precmd_impl() { unset _p9k_preexec_cmd _p9k_keymap=main _p9k_zle_state=insert + + if ! zle; then + (( ++_p9k_prompt_idx )) + fi fi _p9k_refresh_reason=precmd _p9k_set_prompt _p9k_refresh_reason='' - (( init )) && _p9k_dump_state + if ! zle && (( _p9k_prompt_idx == 1 && !_p9k_state_restored || _p9k_prompt_idx == 2 )); then + _p9k_dump_state + fi } _p9k_precmd() { @@ -3638,9 +3671,10 @@ function _p9k_prompt_overflow_bug() { } _p9k_init_vars() { + typeset -gi _p9k_prompt_idx + typeset -gi _p9k_state_restored typeset -gi _p9k_reset_on_line_finish typeset -gF _p9k_timer_start - typeset -gF _p9k_timer_end typeset -gi _p9k_status typeset -ga _p9k_pipestatus typeset -g _p9k_param_sig @@ -3660,6 +3694,7 @@ _p9k_init_vars() { typeset -gA _p9k_last_git_prompt # git workdir => 1 if gitstatus is slow on it, 0 if it's fast. typeset -gA _p9k_git_slow + typeset -gi _p9k_gitstatus_disabled typeset -gF _p9k_gitstatus_start_time typeset -g _p9k_prompt typeset -g _p9k_rprompt @@ -3724,7 +3759,6 @@ _p9k_init_vars() { typeset -g _p9k_uname typeset -g _p9k_uname_o typeset -g _p9k_uname_m - typeset -gi _p9k_gitstatus_disabled typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT @@ -4320,12 +4354,15 @@ _p9k_init_ssh() { } _p9k_must_init() { - local -a param_keys=( - ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) + local -a param_keys=(${(o)parameters[(I)POWERLEVEL9K_*]}) local IFS param_sig IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" - IFS=$'\2' eval "param_sig=0.$USER.$P9K_SSH$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" - [[ -o transient_rprompt ]] && param_sig+=t + param_sig+=( + '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' + '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' + '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v0') + IFS=$'\2' param_sig="#${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit typeset -g _p9k_param_sig=$param_sig @@ -4338,6 +4375,10 @@ function _p9k_set_os() { } function _p9k_init_cacheable() { + (( $+functions[_p9k_init_icons] )) || { + setopt no_aliases + source "${__p9k_root_dir}/internal/icons.zsh" + } _p9k_init_icons _p9k_init_params _p9k_init_prompt @@ -4477,6 +4518,7 @@ function _p9k_init_cacheable() { _p9k_init() { _p9k_init_vars + typeset -g _p9k_state_file=${XDG_CACHE_HOME:-~/.cache}/p10k-state-${(%):-%n}.zsh _p9k_restore_state || _p9k_init_cacheable if _p9k_segment_in_use vcs; then @@ -4779,6 +4821,7 @@ autoload -Uz add-zsh-hook zmodload zsh/datetime zmodload zsh/mathfunc +zmodload zsh/parameter zmodload zsh/system zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket -- cgit v1.2.3 From 4ef1a9bbdd21a2935eb94780b2cb43c6bc042b9e Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 13:46:39 +0200 Subject: add azure prompt segment --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 15 +++++++++++++++ 4 files changed, 34 insertions(+) (limited to 'internal/icons.zsh') diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 1c910039..54d90755 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -59,6 +59,7 @@ kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -658,6 +659,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 7d3d6cba..68c34dbd 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -59,6 +59,7 @@ kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -718,6 +719,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 diff --git a/internal/icons.zsh b/internal/icons.zsh index 718e1663..b93bbb53 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -114,6 +114,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; 'awesome-fontconfig') @@ -215,6 +216,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; 'awesome-mapped-fontconfig') @@ -320,6 +322,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -422,6 +425,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '\uE77F' #  + AZURE_ICON '\uFD03' # ﴃ ) ;; *) @@ -523,6 +527,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 7993fe7a..24239e27 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3035,6 +3035,21 @@ prompt_java_version() { _p9k_prompt_segment "$0" "red" "white" "JAVA_ICON" 0 '' "${v//\%/%%}" } +prompt_azure() { + (( $+commands[az] )) || return + local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json + local -H stat + zstat -H stat -- $cfg 2>/dev/null || return + local sig="$stat[inode].$stat[mtime].$stat[size].$stat[mode]" + if ! _p9k_cache_get $0 || [[ $_p9k_cache_val[1] != $sig ]]; then + local name + name="$(az account show --query name --output tsv 2>/dev/null)" || name= + _p9k_cache_set "$sig" "$name" + fi + [[ -n $_p9k_cache_val[2] ]] || return + _p9k_prompt_segment "$0" "blue" "white" "AZURE_ICON" 0 '' "${_p9k_cache_val[2]//\%/%%}" +} + typeset -gra __p9k_nordvpn_tag=( P9K_NORDVPN_STATUS P9K_NORDVPN_TECHNOLOGY -- cgit v1.2.3 From bb6540ae6ec8617a67167b505db5718436d3f6b8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 23:32:41 +0200 Subject: remove spurious execute permissions --- internal/icons.zsh | 0 internal/p10k.zsh | 0 powerlevel9k.zsh-theme | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 internal/icons.zsh mode change 100755 => 100644 internal/p10k.zsh mode change 100755 => 100644 powerlevel9k.zsh-theme (limited to 'internal/icons.zsh') diff --git a/internal/icons.zsh b/internal/icons.zsh old mode 100755 new mode 100644 diff --git a/internal/p10k.zsh b/internal/p10k.zsh old mode 100755 new mode 100644 diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme old mode 100755 new mode 100644 -- cgit v1.2.3