@ -532,7 +532,7 @@ _p9k_get_icon() {
_p9k_translate_color( ) {
if [ [ $1 = = <-> ] ] ; then # decimal color code: 255
_p9k__ret = ${ (l.3..0.)1 }
elif [ [ $1 = = '#' [ [ :xdigit:] ] ## ]]; then # hexade mi cal color code: #ffffff
elif [ [ $1 = = '#' [ [ :xdigit:] ] ## ]]; then # hexade cim al color code: #ffffff
_p9k__ret = ${ ${ (L)1 } //ı /i }
else # named color: red
# Strip prifixes if there are any.
@ -1314,7 +1314,7 @@ function _p9k_fvm_old() {
}
function _p9k_fvm_new( ) {
_p9k_upglob .fvm @ && return 1
_p9k_upglob .fvm/flutter_sdk @ && return 1
local sdk = $_p9k__parent_dirs [ $? ] /.fvm/flutter_sdk
if [ [ ${ sdk : A } = = ( #b)*/versions/([^/]##) ]]; then
_p9k_prompt_segment prompt_fvm blue $_p9k_color1 FLUTTER_ICON 0 '' ${ match [1]// \% /%% }
@ -1410,6 +1410,9 @@ _p9k_prompt_battery_set_args() {
local -i is_full = 1 is_calculating is_charching
local dir
for dir in $bats ; do
_p9k_read_file $dir /status( N) && local bat_status = $_p9k__ret || continue
# Skip batteries with "Unknown" status: https://github.com/romkatv/powerlevel10k/pull/2562.
[ [ $bat_status = = Unknown ] ] && continue
local -i pow = 0 full = 0
if _p9k_read_file $dir /( energy_full| charge_full| charge_counter) ( N) ; then
( ( energy_full += ${ full : : =_p9k__ret } ) )
@ -1422,7 +1425,6 @@ _p9k_prompt_battery_set_args() {
elif _p9k_read_file $dir /( energy| charge) _now( N) ; then
( ( energy_now += _p9k__ret ) )
fi
_p9k_read_file $dir /status( N) && local bat_status = $_p9k__ret || continue
[ [ $bat_status != Full ] ] && is_full = 0
[ [ $bat_status = = Charging ] ] && is_charching = 1
[ [ $bat_status = = ( Charging| Discharging) && $pow = = 0 ] ] && is_calculating = 1
@ -1747,16 +1749,9 @@ function _p9k_shorten_delim_len() {
# Percents are duplicated because this function is currently used only
# where the result is going to be percent-expanded.
function _p9k_url_escape( ) {
if [ [ $1 = = [ a-zA-Z0-9"/:_.-!'()~ " ] # ]]; then
_p9k__ret = ${ 1 // /%%20 }
else
local c
_p9k__ret =
for c in ${ (s : : )1 } ; do
[ [ $c = = [ a-zA-Z0-9"/:_.-!'()~" ] ] ] || printf -v c '%%%%%02X' $(( #c ))
_p9k__ret += $c
done
fi
emulate -L zsh -o no_multi_byte -o extended_glob
local MATCH MBEGIN MEND
_p9k__ret = ${ 1 //(#m)[^a-zA-Z0-9 "\/:_.-!'()~" ]/%% ${ (l : 2 : : 0 : ) $(( [ ##16]#MATCH))}}
}
################################################################
@ -1911,7 +1906,7 @@ prompt_dir() {
else
local key =
fi
if ! _p9k_cache_ephemeral_get $0 $e $i $_p9k__cwd || [ [ $key != $_p9k__cache_val [ 1] ] ] ; then
if ! _p9k_cache_ephemeral_get $0 $e $i $_p9k__cwd $p || [ [ $key != $_p9k__cache_val [ 1] ] ] ; then
local rtail = ${ (j./.)rparts[i,-1] }
local parent = $_p9k__cwd [ 1,-2-$# rtail]
_p9k_prompt_length $delim
@ -2324,7 +2319,11 @@ prompt_laravel_version() {
[ [ -r $app ] ] || return
if ! _p9k_cache_stat_get $0 $dir /artisan $app ; then
local v = " $( php $dir /artisan --version 2> /dev/null) "
_p9k_cache_stat_set " ${ ${ (M)v : #Laravel Framework * } #Laravel Framework } "
v = " ${ ${ (M)v : #Laravel Framework * } #Laravel Framework } "
# In some versions the output is colorized.
# https://github.com/romkatv/powerlevel10k/issues/2534
v = ${ ${ v # $'\e[' <->m } % $'\e[' <->m }
_p9k_cache_stat_set " $v "
fi
[ [ -n $_p9k__cache_val [ 1] ] ] || return
_p9k_prompt_segment " $0 " "maroon" "white" 'LARAVEL_ICON' 0 '' " ${ _p9k__cache_val [1]// \% /%% } "
@ -2427,18 +2426,45 @@ function _p9k_cached_cmd() {
}
################################################################
# Segment to di play Node version
# Segment to di s play Node version
prompt_node_version( ) {
_p9k_upglob package.json -.
local -i idx = $?
if ( ( idx ) ) ; then
_p9k_cached_cmd 0 $_p9k__parent_dirs [ idx] /package.json node --version || return
else
( ( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY ) ) && return
_p9k_cached_cmd 0 '' node --version || return
( ( idx || ! _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY ) ) || return
local node = $commands [ node]
local -a file_deps env_deps
if [ [ $node = = ${ NODENV_ROOT :- $HOME /.nodenv } /shims/node ] ] ; then
env_deps += ( " $NODENV_VERSION " )
file_deps += ( ${ NODENV_ROOT :- $HOME /.nodenv } /version)
if [ [ $NODENV_DIR != ( | .) ] ] ; then
[ [ $NODENV_DIR = = /* ] ] && local dir = $NODENV_DIR || local dir = " $_p9k__cwd_a / $NODENV_DIR "
dir = ${ dir : A }
if [ [ $dir != $_p9k__cwd_a ] ] ; then
while true; do
if [ [ -e $dir /.node-version ] ] ; then
file_deps += ( $dir /.node-version)
break
fi
[ [ $dir = = ( /| .) ] ] && break
dir = ${ dir : h }
done
fi
fi
_p9k_upglob .node-version -. || file_deps += ( $_p9k__parent_dirs [ idx] /.node-version)
elif ( ( idx ) ) ; then
file_deps += ( $_p9k__parent_dirs [ idx] /package.json)
fi
if ! _p9k_cache_stat_get " $0 $# env_deps ${ (j : : ) ${ (@q)env_deps } } ${ (j : : ) ${ (@q)file_deps } } " $file_deps $node ; then
local out
out = $( $node --version 2>/dev/null)
_p9k_cache_stat_set $(( ! $? )) " $out "
fi
[ [ $_p9k__ret = = v?* ] ] || return
_p9k_prompt_segment " $0 " "green" "white" 'NODE_ICON' 0 '' " ${ _p9k__ret #v } "
( ( $_p9k__cache_val [ 1] ) ) || return
local v = $_p9k__cache_val [ 2]
[ [ $v = = v?* ] ] || return
_p9k_prompt_segment " $0 " "green" "white" 'NODE_ICON' 0 '' " ${ ${ v #v } // \% /%% } "
}
_p9k_prompt_node_version_init( ) {
@ -2547,7 +2573,13 @@ _p9k_nvm_ls_current() {
prompt_nvm( ) {
[ [ -n $NVM_DIR ] ] && _p9k_nvm_ls_current || return
local current = $_p9k__ret
! _p9k_nvm_ls_default || [ [ $_p9k__ret != $current ] ] || return
( ( _POWERLEVEL9K_NVM_SHOW_SYSTEM ) ) ||
[ [ $current != system ] ] ||
return
( ( _POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW ) ) ||
! _p9k_nvm_ls_default ||
[ [ $_p9k__ret != $current ] ] ||
return
_p9k_prompt_segment " $0 " "magenta" "black" 'NODE_ICON' 0 '' " ${ ${ current #v } // \% /%% } "
}
@ -3160,68 +3192,55 @@ instant_prompt_root_indicator() { prompt_root_indicator; }
################################################################
# Segment to display Rust version number
prompt_rust_version( ) {
unset P9K_RUST_VERSION
if ( ( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY ) ) ; then
_p9k_upglob Cargo.toml -. && return
fi
local rustc = $commands [ rustc] toolchain deps = ( )
if ( ( $+commands[ ldd] ) ) ; then
if ! _p9k_cache_stat_get $0 _so $rustc ; then
local line so
for line in " ${ (@f) $( ldd $rustc 2>/dev/null) } " ; do
[ [ $line = = ( #b)[[:space:]]#librustc_driver[^[:space:]]#.so' => '(*)' (0x'[[:xdigit:]]#')' ]] || continue
so = $match [ 1]
break
done
_p9k_cache_stat_set " $so "
fi
deps += $_p9k__cache_val [ 1]
fi
if ( ( $+commands[ rustup] ) ) ; then
local rustup = $commands [ rustup]
local rustup_home = ${ RUSTUP_HOME :- ~/.rustup }
local cfg = ( $rustup_home /settings.toml( .N) )
deps += ( $cfg $rustup_home /update-hashes/*( .N) )
if [ [ -z ${ toolchain : : = $RUSTUP_TOOLCHAIN } ] ] ; then
if ! _p9k_cache_stat_get $0 _overrides $rustup $cfg ; then
local lines = ( ${ (f) " $( rustup override list 2>/dev/null) " } )
if [ [ $lines [ 1] = = "no overrides" ] ] ; then
_p9k_cache_stat_set
else
local MATCH
local keys = ( ${ (@) ${ lines %%[[ : space : ]]#[^[ : space : ]]# } /(#m)*/ ${ (b)MATCH } / } )
local vals = ( ${ (@)lines/(#m)*/ $MATCH [(I)/] ${ MATCH ##*[[ : space : ]] } } )
_p9k_cache_stat_set ${ keys : ^vals }
fi
fi
local -A overrides = ( $_p9k__cache_val )
_p9k_upglob rust-toolchain -.
local dir = $_p9k__parent_dirs [ $? ]
local -i n m = ${ dir [(I)/] }
local pair
for pair in ${ overrides [(K) $_p9k__cwd /] } ; do
n = ${ pair %% * }
( ( n <= m ) ) && continue
m = n
toolchain = ${ pair #* }
done
if [ [ -z $toolchain && -n $dir ] ] ; then
_p9k_read_word $dir /rust-toolchain
toolchain = $_p9k__ret
fi
fi
local -i len = $# _p9k__prompt _p9k__has_upglob
_p9k_prompt_segment $0 darkorange $_p9k_color1 RUST_ICON 1 '$P9K_RUST_VERSION' '${P9K_RUST_VERSION//\%/%%}'
( ( _p9k__has_upglob ) ) || typeset -g " _p9k__segment_val_ ${ _p9k__prompt_side } [_p9k__segment_index] " = $_p9k__prompt [ len+1,-1]
}
function _p9k_prompt_rust_version_init( ) {
_p9k__async_segments_compute += '_p9k_rust_version_prefetch'
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = '$commands[rustc]'
}
_p9k_rust_version_prefetch( ) {
local rustc = $commands [ rustc]
if [ [ -z $rustc ] ] ||
{ ( ( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY ) ) && _p9k_upglob Cargo.toml -. } ; then
unset P9K_RUST_VERSION
return
fi
if ! _p9k_cache_stat_get $0 _v$toolchain $rustc $deps ; then
_p9k_cache_stat_set " $( $rustc --version 2>/dev/null) "
_p9k_worker_invoke rust_version \
" _p9k_prompt_rust_version_compute ${ (q)P9K_RUST_VERSION } ${ (q)rustc } ${ (q)_p9k__cwd_a } "
}
_p9k_prompt_rust_version_compute( ) {
_p9k_worker_async \
" _p9k_prompt_rust_version_async ${ (q)1 } ${ (q)2 } ${ (q)3 } " \
_p9k_prompt_rust_version_sync
}
_p9k_prompt_rust_version_async( ) {
typeset -g P9K_RUST_VERSION = $1
local rustc = $2 cwd = $3 v
if pushd -q -- $cwd ; then
{
v = ${ ${ " $( $rustc --version) " #rustc } %% * } || v =
} always {
popd -q
}
fi
local v = ${ ${ _p9k__cache_val [1]#rustc } %% * }
[ [ -n $v ] ] || return
typeset -g P9K_RUST_VERSION = $_p9k__cache_val [ 1]
_p9k_prompt_segment " $0 " "darkorange" " $_p9k_color1 " 'RUST_ICON' 0 '' " ${ v // \% /%% } "
[ [ $v != $P9K_RUST_VERSION ] ] || return
typeset -g P9K_RUST_VERSION = $v
_p9k_print_params P9K_RUST_VERSION
echo -E - 'reset=1'
}
_p9k_prompt_rust_version_init( ) {
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = '$commands[rustc]'
_p9k_prompt_rust_version_sync( ) {
if [ [ -n $REPLY ] ] ; then
eval $REPLY
_p9k_worker_reply $REPLY
fi
}
# RSpec test ratio
@ -3692,7 +3711,7 @@ function +vi-hg-bookmarks() {
if [ [ -n " ${ hgbmarks [@] } " ] ] ; then
hook_com[ hg-bookmark-string] = " $( print_icon 'VCS_BOOKMARK_ICON' ) ${ hgbmarks [@] } "
# To signal that we want to use the st ing we just generated, set the special
# To signal that we want to use the st r ing we just generated, set the special
# variable `ret' to something other than the default zero:
ret = 1
return 0
@ -3701,20 +3720,9 @@ function +vi-hg-bookmarks() {
function +vi-vcs-detect-changes( ) {
if [ [ " ${ hook_com [vcs] } " = = "git" ] ] ; then
local remote = " $( git ls-remote --get-url 2> /dev/null) "
if [ [ " $remote " = ~ "github" ] ] then
vcs_visual_identifier = 'VCS_GIT_GITHUB_ICON'
elif [ [ " $remote " = ~ "bitbucket" ] ] then
vcs_visual_identifier = 'VCS_GIT_BITBUCKET_ICON'
elif [ [ " $remote " = ~ "stash" ] ] then
vcs_visual_identifier = 'VCS_GIT_BITBUCKET_ICON'
elif [ [ " $remote " = ~ "gitlab" ] ] then
vcs_visual_identifier = 'VCS_GIT_GITLAB_ICON'
else
vcs_visual_identifier = 'VCS_GIT_ICON'
fi
_p9k_vcs_icon " $remote "
vcs_visual_identifier = $_p9k__ret
elif [ [ " ${ hook_com [vcs] } " = = "hg" ] ] ; then
vcs_visual_identifier = 'VCS_HG_ICON'
elif [ [ " ${ hook_com [vcs] } " = = "svn" ] ] ; then
@ -3847,13 +3855,14 @@ function _p9k_vcs_status_purge() {
}
function _p9k_vcs_icon( ) {
case " $VCS_STATUS_REMOTE_URL " in
*github*) _p9k__ret = VCS_GIT_GITHUB_ICON; ;
*bitbucket*) _p9k__ret = VCS_GIT_BITBUCKET_ICON; ;
*stash*) _p9k__ret = VCS_GIT_BITBUCKET_ICON; ;
*gitlab*) _p9k__ret = VCS_GIT_GITLAB_ICON; ;
*) _p9k__ret = VCS_GIT_ICON; ;
esac
local pat icon
for pat icon in " ${ (@)_POWERLEVEL9K_VCS_GIT_REMOTE_ICONS } " ; do
if [ [ $1 = = $~pat ] ] ; then
_p9k__ret = $icon
return
fi
done
_p9k__ret =
}
function _p9k_vcs_render( ) {
@ -3883,7 +3892,7 @@ function _p9k_vcs_render() {
state = CLEAN
fi
fi
_p9k_vcs_icon
_p9k_vcs_icon " $VCS_STATUS_REMOTE_URL "
_p9k_prompt_segment prompt_vcs_$state " ${ __p9k_vcs_states [ $state ] } " " $_p9k_color1 " " $_p9k__ret " 0 '' ""
return 0
fi
@ -3936,8 +3945,8 @@ function _p9k_vcs_render() {
fi
# It's weird that removing vcs-detect-changes from POWERLEVEL9K_VCS_GIT_HOOKS gets rid
# of the GIT icon. That's what vcs_info does, so we do the same in the name of compatib lity.
_p9k_vcs_icon
# of the GIT icon. That's what vcs_info does, so we do the same in the name of compatib i lity.
_p9k_vcs_icon " $VCS_STATUS_REMOTE_URL "
icon = $_p9k__ret
fi
@ -4234,6 +4243,49 @@ instant_prompt_vi_mode() {
fi
}
# Chezmoi shell indicator: https://www.chezmoi.io/
prompt_chezmoi_shell( ) {
_p9k_prompt_segment $0 blue $_p9k_color1 CHEZMOI_ICON 0 '' ''
}
_p9k_prompt_chezmoi_shell_init( ) {
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = '$CHEZMOI'
}
function instant_prompt_chezmoi_shell( ) {
_p9k_prompt_segment prompt_chezmoi_shell blue $_p9k_color1 CHEZMOI_ICON 1 '$CHEZMOI_ICON' ''
}
function _p9k_parse_virtualenv_cfg( ) {
typeset -ga reply = ( 0)
[ [ -f $1 && -r $1 ] ] || return
local cfg
cfg = $( <$1 ) || return
local -a match mbegin mend
[ [ $'\n' $cfg $'\n' = = ( #b)*$'\n'prompt[$' \t']#=([^$'\n']#)$'\n'* ]] || return
local res = ${ ${ match [1]##[ $' \t' ]# } %%[ $' \t' ]# }
if [ [ $res = = ( \" *\" | \' *\' ) ] ] ; then
# The string is quoted in python style, which isn't the same as quoting in zsh.
# For example, the literal 'foo"\'bar' denotes foo"'bar in python but in zsh
# it is malformed.
#
# We cheat a bit and impelement not exactly correct unquoting. It may produce
# different visual results but won't perform unintended expansions or bleed out
# any escape sequences.
#
# Note that venv performs unusual and obviously unintended expansions on the
# value of `prompt`: single-word expansions are performed twice by `activate`,
# and then again on every prompt if `prompt_subst` is in effect. While in general
# I am OK with being bug-compatible with other software, the bugs in venv are a
# bit too extreme for my comfort. I am going to disable all expansions and
# display the configured prompt literally.
res = ${ (Vg : e : ) ${ res [2,-2] } }
fi
reply = ( 1 " $res " )
}
################################################################
# Virtualenv: current working virtualenv
# More information on virtualenv (Python):
@ -4243,11 +4295,21 @@ prompt_virtualenv() {
if ( ( _POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION ) ) && _p9k_python_version; then
msg = " ${ _p9k__ret // \% /%% } "
fi
local v = ${ VIRTUAL_ENV : t }
if [ [ $VIRTUAL_ENV_PROMPT = = '(' ?*') ' && $VIRTUAL_ENV_PROMPT != " ( $v ) " ] ] ; then
v = $VIRTUAL_ENV_PROMPT [ 2,-3]
elif [ [ $v = = $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ] ] ; then
v = ${ VIRTUAL_ENV : h : t }
local cfg = $VIRTUAL_ENV /pyvenv.cfg
if ! _p9k_cache_stat_get $0 $cfg ; then
local -a reply
_p9k_parse_virtualenv_cfg $cfg
_p9k_cache_stat_set " ${ reply [@] } "
fi
if ( ( _p9k__cache_val[ 1] ) ) ; then
local v = $_p9k__cache_val [ 2]
else
local v = ${ VIRTUAL_ENV : t }
if [ [ $VIRTUAL_ENV_PROMPT = = '(' ?*') ' && $VIRTUAL_ENV_PROMPT != " ( $v ) " ] ] ; then
v = $VIRTUAL_ENV_PROMPT [ 2,-3]
elif [ [ $v = = $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ] ] ; then
v = ${ VIRTUAL_ENV : h : t }
fi
fi
msg += " $_POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER ${ v // \% /%% } $_POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER "
case $_POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV in
@ -4604,9 +4666,10 @@ _p9k_prompt_java_version_init() {
}
prompt_azure( ) {
local cfg = ${ AZURE_CONFIG_DIR :- $HOME /.azure } /azureProfile.json
if ! _p9k_cache_stat_get $0 $cfg ; then
local name
local name cfg = ${ AZURE_CONFIG_DIR :- $HOME /.azure } /azureProfile.json
if _p9k_cache_stat_get $0 $cfg ; then
name = $_p9k__cache_val [ 1]
else
if ( ( $+commands[ jq] ) ) && name = " $( jq -r '[.subscriptions[]|select(.isDefault==true)|.name][]|strings' $cfg 2>/dev/null) " ; then
name = ${ name %% $'\n' * }
elif ! name = " $( az account show --query name --output tsv 2>/dev/null) " ; then
@ -4614,6 +4677,7 @@ prompt_azure() {
fi
_p9k_cache_stat_set " $name "
fi
[ [ -n $name ] ] || return
local pat class state
for pat class in " ${ _POWERLEVEL9K_AZURE_CLASSES [@] } " ; do
if [ [ $name = = ${ ~pat } ] ] ; then
@ -4621,8 +4685,7 @@ prompt_azure() {
break
fi
done
[ [ -n $_p9k__cache_val [ 1] ] ] || return
_p9k_prompt_segment " $0 $state " "blue" "white" "AZURE_ICON" 0 '' " ${ _p9k__cache_val [1]// \% /%% } "
_p9k_prompt_segment " $0 $state " "blue" "white" "AZURE_ICON" 0 '' " ${ name // \% /%% } "
}
_p9k_prompt_azure_init( ) {
@ -4892,6 +4955,18 @@ function instant_prompt_ranger() {
_p9k_prompt_segment prompt_ranger $_p9k_color1 yellow RANGER_ICON 1 '$RANGER_LEVEL' '$RANGER_LEVEL'
}
function prompt_yazi( ) {
_p9k_prompt_segment $0 $_p9k_color1 yellow YAZI_ICON 0 '' $YAZI_LEVEL
}
_p9k_prompt_yazi_init( ) {
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = '$YAZI_LEVEL'
}
function instant_prompt_yazi( ) {
_p9k_prompt_segment prompt_yazi $_p9k_color1 yellow YAZI_ICON 1 '$YAZI_LEVEL' '$YAZI_LEVEL'
}
function prompt_midnight_commander( ) {
local -i len = $# _p9k__prompt _p9k__has_upglob
_p9k_prompt_segment $0 $_p9k_color1 yellow MIDNIGHT_COMMANDER_ICON 0 '' ''
@ -4963,13 +5038,11 @@ function prompt_nix_shell() {
}
_p9k_prompt_nix_shell_init( ) {
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = '${IN_NIX_SHELL:#0}${${path[(I)/nix/store/*]}:#0}'
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = $_p9k_nix_shell_cond
}
function instant_prompt_nix_shell( ) {
_p9k_prompt_segment prompt_nix_shell 4 $_p9k_color1 NIX_SHELL_ICON 1 \
'${IN_NIX_SHELL:#0}${${path[(I)/nix/store/*]}:#0}' \
'${(M)IN_NIX_SHELL:#(pure|impure)}'
_p9k_prompt_segment prompt_nix_shell 4 $_p9k_color1 NIX_SHELL_ICON 1 " $_p9k_nix_shell_cond " '${(M)IN_NIX_SHELL:#(pure|impure)}'
}
function prompt_terraform( ) {
@ -4993,12 +5066,16 @@ _p9k_prompt_terraform_init() {
}
function prompt_terraform_version( ) {
_p9k_cached_cmd 0 '' terraform --version || return
local v = ${ _p9k__ret #Terraform v }
( ( $# v < $# _p9k__ret ) ) || return
v = ${ v %% $'\n' * }
local v cfg terraform = ${ commands [terraform] }
_p9k_upglob .terraform-version -. || cfg = $_p9k__parent_dirs [ $? ] /.terraform-version
if _p9k_cache_stat_get $0 .$TFENV_TERRAFORM_VERSION $terraform $cfg ; then
v = $_p9k__cache_val [ 1]
else
v = ${ ${ " $( terraform --version 2>/dev/null) " #Terraform v } %% $'\n' * } || v =
_p9k_cache_stat_set " $v "
fi
[ [ -n $v ] ] || return
_p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $v
_p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' ${ v // \% /%% }
}
_p9k_prompt_terraform_version_init( ) {
@ -5047,8 +5124,11 @@ function _p9k_timewarrior_clear() {
}
function prompt_timewarrior( ) {
local dir
[ [ -n ${ dir : : = $TIMEWARRIORDB } || -n ${ dir : : =~/.timewarrior } ( #q-/N) ]] ||
dir = ${ XDG_DATA_HOME :- ~/.local/share } /timewarrior
dir += /data
local -a stat
local dir = ${ TIMEWARRIORDB :- ~/.timewarrior } /data
[ [ $dir = = $_p9k_timewarrior_dir ] ] || _p9k_timewarrior_clear
if [ [ -n $_p9k_timewarrior_file_name ] ] ; then
zstat -A stat +mtime -- $dir $_p9k_timewarrior_file_name 2>/dev/null || stat = ( )
@ -5154,7 +5234,10 @@ function _p9k_taskwarrior_check_data() {
}
function _p9k_taskwarrior_init_data( ) {
local -a stat files = ( $_p9k_taskwarrior_data_dir /{ pending,completed} .data)
local -a stat files = (
$_p9k_taskwarrior_data_dir /{ pending,completed} .data
$_p9k_taskwarrior_data_dir /taskchampion.sqlite3
)
_p9k_taskwarrior_data_files = ( $^files( N) )
_p9k_taskwarrior_data_non_files = ( ${ files : |_p9k_taskwarrior_data_files } )
if ( ( $# _p9k_taskwarrior_data_files ) ) ; then
@ -5181,7 +5264,9 @@ function _p9k_taskwarrior_init_data() {
local -a ts
ts = ( $( command task +PENDING -OVERDUE list rc.verbose= nothing rc.color= 0 rc._forcecolor= 0 \
rc.report.list.labels= rc.report.list.columns= due.epoch </dev/null 2>/dev/null) ) || ts = ( )
if ( ( $# ts ) ) ; then
# The second condition is a workaround for a bug in taskwarrior v3.0.1.
# https://github.com/romkatv/powerlevel10k/issues/2648.
if ( ( $# ts && ! ${# ${ (@)ts : #(|-)<->(|.<->) } } ) ) ; then
_p9k_taskwarrior_next_due = ${ ${ (on)ts } [1] }
( ( _p9k_taskwarrior_next_due > EPOCHSECONDS ) ) || _p9k_taskwarrior_next_due = $(( EPOCHSECONDS+60))
fi
@ -5690,6 +5775,31 @@ _p9k_prompt_cpu_arch_init() {
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = '$commands[machine]$commands[arch]'
}
################################################################
# Oh My Zsh per-directory-history local/global indicator
prompt_per_directory_history( ) {
if [ [ $_per_directory_history_is_global = = true ] ] ; then
_p9k_prompt_segment ${ 0 } _GLOBAL 3 $_p9k_color1 HISTORY_ICON 0 '' global
else
_p9k_prompt_segment ${ 0 } _LOCAL 5 $_p9k_color1 HISTORY_ICON 0 '' local
fi
}
instant_prompt_per_directory_history( ) {
case $HISTORY_START_WITH_GLOBAL in
true )
_p9k_prompt_segment prompt_per_directory_history_GLOBAL 3 $_p9k_color1 HISTORY_ICON 0 '' global
; ;
?*)
_p9k_prompt_segment prompt_per_directory_history_LOCAL 5 $_p9k_color1 HISTORY_ICON 0 '' local
; ;
esac
}
_p9k_prompt_per_directory_history_init( ) {
typeset -g " _p9k__segment_cond_ ${ _p9k__prompt_side } [_p9k__segment_index] " = '$PER_DIRECTORY_HISTORY_TOGGLE'
}
# Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with
# YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427.
_p9k_preexec1( ) {
@ -6581,9 +6691,12 @@ function _p9k_clear_instant_prompt() {
unset _z4h_saved_screen
fi
print -rn -- $terminfo [ rc] ${ (%) :- %b%k%f%s%u } $terminfo [ ed]
local unexpected = ${ (S) ${ ${ content // $'\e[?' <-> 'c' } // $'\e[' <-> ' q' } // $'\e' [^ $'\a\e' ]#( $'\a' | $'\e\\' ) }
local unexpected = ${ ${ content // $'\e[?' <-> 'c' } // $'\e[' <-> ' q' }
unexpected = ${ (S)unexpected// $'\eP' (|*[^ $'\e' ])( $'\e\e' )# $'\e\\' }
unexpected = ${ (S)unexpected// $'\e' [^ $'\a\e' ]#( $'\a' | $'\e\\' ) }
# Visual Studio Code prints this garbage.
unexpected = ${ ${ unexpected // $'\033[1;32mShell integration activated\033[0m\n' } // $'\r' }
typeset -g P9K_STARTUP_CONSOLE_OUTPUT = ( " $content " " $unexpected " )
if [ [ -n $unexpected ] ] ; then
local omz1 = '[Oh My Zsh] Would you like to update? [Y/n]: '
local omz2 = 'Updating Oh My Zsh'
@ -6627,9 +6740,9 @@ function _p9k_clear_instant_prompt() {
echo -E - ""
echo -E - " ${ (%) :- For details, see : } "
if ( ( _p9k_term_has_href ) ) ; then
echo - " ${ (%) :- \e ]8;;https : //github.com/romkatv/powerlevel10k /blob/master/README.md #instant-prompt\a https : //github.com/romkatv/powerlevel10k /blob/master/README.md #instant-prompt\e ]8;; \a } "
echo - " ${ (%) :- \e ]8;;https : //github.com/romkatv/powerlevel10k #instant-prompt\a https : //github.com/romkatv/powerlevel10k #instant-prompt\e ]8;; \a } "
else
echo - " ${ (%) :- https : //github.com/romkatv/powerlevel10k /blob/master/README.md #instant-prompt} "
echo - " ${ (%) :- https : //github.com/romkatv/powerlevel10k #instant-prompt} "
fi
echo -E - ""
echo - " ${ (%) :- %3F-- console output produced during zsh initialization follows --%f } "
@ -7341,6 +7454,36 @@ _p9k_init_params() {
_p9k_declare -b POWERLEVEL9K_VCS_CONFLICTED_STATE 0
_p9k_declare -b POWERLEVEL9K_HIDE_BRANCH_ICON 0
_p9k_declare -b POWERLEVEL9K_VCS_HIDE_TAGS 0
_p9k_declare -a POWERLEVEL9K_VCS_GIT_REMOTE_ICONS
if ( ( $+_POWERLEVEL9K_VCS_GIT_REMOTE_ICONS ) ) ; then
( ( $# _POWERLEVEL9K_VCS_GIT_REMOTE_ICONS & 1 ) ) && _POWERLEVEL9K_VCS_GIT_REMOTE_ICONS += ( '' )
else
local domain = icon = domain2icon = (
'archlinux.org' VCS_GIT_ARCHLINUX_ICON
'dev.azure.com|visualstudio.com' VCS_GIT_AZURE_ICON
'bitbucket.org' VCS_GIT_BITBUCKET_ICON
'codeberg.org' VCS_GIT_CODEBERG_ICON
'debian.org' VCS_GIT_DEBIAN_ICON
'freebsd.org' VCS_GIT_FREEBSD_ICON
'freedesktop.org' VCS_GIT_FREEDESKTOP_ICON
'gitea.com|gitea.io' VCS_GIT_GITEA_ICON
'github.com' VCS_GIT_GITHUB_ICON
'gitlab.com' VCS_GIT_GITLAB_ICON
'gnome.org' VCS_GIT_GNOME_ICON
'gnu.org' VCS_GIT_GNU_ICON
'kde.org' VCS_GIT_KDE_ICON
'kernel.org' VCS_GIT_LINUX_ICON
'sr.ht' VCS_GIT_SOURCEHUT_ICON
)
typeset -ga _POWERLEVEL9K_VCS_GIT_REMOTE_ICONS
for domain icon in " ${ domain2icon [@] } " ; do
_POWERLEVEL9K_VCS_GIT_REMOTE_ICONS += (
'(|[A-Za-z0-9][A-Za-z0-9+.-]#://)(|[^:/?#]#[.@])((#i)' $domain ')(|[/:?#]*)'
$icon
)
done
_POWERLEVEL9K_VCS_GIT_REMOTE_ICONS += ( '*' VCS_GIT_ICON)
fi
_p9k_declare -i POWERLEVEL9K_CHANGESET_HASH_LENGTH 8
# Specifies the maximum number of elements in the cache. When the cache grows over this limit,
# it gets cleared. This is meant to avoid memory leaks when a rogue prompt is filling the cache
@ -7512,6 +7655,8 @@ _p9k_init_params() {
_p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_NODENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_NODENV_SHOW_SYSTEM 1
_p9k_declare -b POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW 0
_p9k_declare -b POWERLEVEL9K_NVM_SHOW_SYSTEM 1
_p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_RBENV_SHOW_SYSTEM 1
@ -7593,6 +7738,7 @@ _p9k_init_params() {
_p9k_declare -i POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM -1
_p9k_declare -i POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM -1
_p9k_declare -b POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS 0
_p9k_declare -F POWERLEVEL9K_GITSTATUS_INIT_TIMEOUT_SEC 10
_p9k_declare -b POWERLEVEL9K_DISABLE_GITSTATUS 0
_p9k_declare -e POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT"
_p9k_declare -e POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL"
@ -7658,6 +7804,12 @@ _p9k_init_params() {
# If set to true, time will update every second.
_p9k_declare -b POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME 0
_p9k_declare -b POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH 0
typeset -g _p9k_nix_shell_cond = '${IN_NIX_SHELL:#0}'
if ( ( _POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH ) ) ; then
_p9k_nix_shell_cond += '${path[(r)/nix/store/*]}'
fi
local -i i = 1
while ( ( i <= $# _POWERLEVEL9K_LEFT_PROMPT_ELEMENTS ) ) ; do
local segment = ${ ${ (U)_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i] } //İ/I }
@ -8230,9 +8382,17 @@ _p9k_init_prompt() {
if ( ( _POWERLEVEL9K_TERM_SHELL_INTEGRATION ) ) ; then
_p9k_prompt_prefix_left += $'%{\e]133;A\a%}'
_p9k_prompt_suffix_left += $'%{\e]133;B\a%}'
if [ [ $TERM_PROGRAM = = WarpTerminal ] ] ; then
_p9k_prompt_prefix_right = $'%{\e]133;P;k=r\a%}' $_p9k_prompt_prefix_right
_p9k_prompt_suffix_right += $'%{\e]133;B\a%}'
fi
if ( ( $+_z4h_iterm_cmd && _z4h_can_save_restore_screen = = 1 ) ) ; then
_p9k_prompt_prefix_left += $'%{\ePtmux;\e\e]133;A\a\e\\%}'
_p9k_prompt_suffix_left += $'%{\ePtmux;\e\e]133;B\a\e\\%}'
if [ [ $TERM_PROGRAM = = WarpTerminal ] ] ; then
_p9k_prompt_prefix_right = $'%{\ePtmux;\e\e]133;P;k=r\a\e\\%}' $_p9k_prompt_prefix_right
_p9k_prompt_suffix_right += $'%{\ePtmux;\e\e]133;B\a\e\\%}'
fi
fi
fi
@ -8357,8 +8517,8 @@ _p9k_must_init() {
[ [ $sig = = $_p9k__param_sig ] ] && return 1
_p9k_deinit
fi
_p9k__param_pat = $' v141 \1'${ (q)ZSH_VERSION } $'\1' ${ (q)ZSH_PATCHLEVEL } $'\1'
_p9k__param_pat += $__p9k_force_term_shell_integration $'\1'
_p9k__param_pat = ${ (q)P9K_VERSION } $' \1'${ (q)ZSH_VERSION } $'\1' ${ (q)ZSH_PATCHLEVEL } $'\1'
_p9k__param_pat += $__p9k_force_term_shell_integration $'\1' ${ (q)TERM_PROGRAM } $'\1'
_p9k__param_pat += $'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat += $'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat += $'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1'
@ -8430,7 +8590,14 @@ function _p9k_init_cacheable() {
_p9k_transient_prompt += '${${P9K_CONTENT::="❯ "}+}'
_p9k_param prompt_prompt_char_ERROR_VIINS CONTENT_EXPANSION '${P9K_CONTENT}'
_p9k_transient_prompt += '${:-"' $_p9k__ret '"}'
_p9k_transient_prompt += ')%b%k%f%s%u '
_p9k_transient_prompt += ')%b%k%f%s%u'
_p9k_get_icon '' LEFT_SEGMENT_END_SEPARATOR
if [ [ $_p9k__ret != ( | ) ] ] ; then
_p9k__ret += %b%k%f
# Not escaped for historical reasons.
_p9k__ret = '${:-"' $_p9k__ret '"}'
fi
_p9k_transient_prompt += $_p9k__ret
if ( ( _POWERLEVEL9K_TERM_SHELL_INTEGRATION ) ) ; then
_p9k_transient_prompt = $'%{\e]133;A\a%}' $_p9k_transient_prompt $'%{\e]133;B\a%}'
if ( ( $+_z4h_iterm_cmd && _z4h_can_save_restore_screen = = 1 ) ) ; then
@ -8457,18 +8624,25 @@ function _p9k_init_cacheable() {
if [ [ -r /etc/os-release ] ] ; then
local lines = ( ${ (f) " $( </etc/os-release) " } )
lines = ( ${ (@M)lines : #ID=* } )
( ( $# lines = = 1 ) ) && os_release_id = ${ lines [1]#ID= }
( ( $# lines = = 1 ) ) && os_release_id = ${ (Q) ${ lines [1]#ID= } }
elif [ [ -e /etc/artix-release ] ] ; then
os_release_id = artix
fi
case $os_release_id in
*arch*) _p9k_set_os Linux LINUX_ARCH_ICON; ;
*debian*) _p9k_set_os Linux LINUX_DEBIAN_ICON; ;
*raspbian*) _p9k_set_os Linux LINUX_RASPBIAN_ICON; ;
*debian*)
if [ [ -f /etc/apt/sources.list.d/raspi.list ] ] ; then
_p9k_set_os Linux LINUX_RASPBIAN_ICON
else
_p9k_set_os Linux LINUX_DEBIAN_ICON
fi
; ;
*ubuntu*) _p9k_set_os Linux LINUX_UBUNTU_ICON; ;
*elementary*) _p9k_set_os Linux LINUX_ELEMENTARY_ICON; ;
*fedora*) _p9k_set_os Linux LINUX_FEDORA_ICON; ;
*coreos*) _p9k_set_os Linux LINUX_COREOS_ICON; ;
*kali*) _p9k_set_os Linux LINUX_KALI_ICON; ;
*gentoo*) _p9k_set_os Linux LINUX_GENTOO_ICON; ;
*mageia*) _p9k_set_os Linux LINUX_MAGEIA_ICON; ;
*centos*) _p9k_set_os Linux LINUX_CENTOS_ICON; ;
@ -8486,6 +8660,9 @@ function _p9k_init_cacheable() {
*rhel*) _p9k_set_os Linux LINUX_RHEL_ICON; ;
amzn) _p9k_set_os Linux LINUX_AMZN_ICON; ;
endeavouros) _p9k_set_os Linux LINUX_ENDEAVOUROS_ICON; ;
rocky) _p9k_set_os Linux LINUX_ROCKY_ICON; ;
guix) _p9k_set_os Linux LINUX_GUIX_ICON; ;
neon) _p9k_set_os Linux LINUX_NEON_ICON; ;
*) _p9k_set_os Linux LINUX_ICON; ;
esac
; ;
@ -8636,7 +8813,7 @@ _p9k_init_vcs() {
( ) {
trap 'return 130' INT
{
gitstatus_start_p9k_ POWERLEVEL9K
gitstatus_start_p9k_ -t $_POWERLEVEL9K_GITSTATUS_INIT_TIMEOUT_SEC POWERLEVEL9K
} always {
trap ':' INT
}
@ -8680,6 +8857,7 @@ _p9k_init_vcs() {
-d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \
-c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \
-m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \
-t $_POWERLEVEL9K_GITSTATUS_INIT_TIMEOUT_SEC \
${ ${ _POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS : #0 } : +-e } \
POWERLEVEL9K
} always {
@ -8829,9 +9007,9 @@ _p9k_init() {
>& 2 echo -E - ""
>& 2 echo -E - " ${ (%) :- - %BRecommended%b : Change the way Powerlevel10k is loaded from %B $__p9k_zshrc_u %b. } "
if ( ( _p9k_term_has_href ) ) ; then
>& 2 echo - " ${ (%) :- See \e ]8;;https : //github.com/romkatv/powerlevel10k /blob/master/README.md #installation\a https : //github.com/romkatv/powerlevel10k /blob/master/README.md #installation\e ]8;; \a . } "
>& 2 echo - " ${ (%) :- See \e ]8;;https : //github.com/romkatv/powerlevel10k #installation\a https : //github.com/romkatv/powerlevel10k #installation\e ]8;; \a . } "
else
>& 2 echo - " ${ (%) :- See https : //github.com/romkatv/powerlevel10k /blob/master/README.md #installation.} "
>& 2 echo - " ${ (%) :- See https : //github.com/romkatv/powerlevel10k #installation.} "
fi
if ( ( $+zsh_defer_options ) ) ; then
>& 2 echo -E - ""
@ -8904,6 +9082,8 @@ _p9k_precmd_first() {
if [ [ -n $KITTY_SHELL_INTEGRATION && KITTY_SHELL_INTEGRATION[ ( wIe) no-prompt-mark] -eq 0 ] ] ; then
KITTY_SHELL_INTEGRATION += ' no-prompt-mark'
( ( $+__p9k_force_term_shell_integration ) ) || typeset -gri __p9k_force_term_shell_integration = 1
elif [ [ $TERM_PROGRAM = = WarpTerminal ] ] ; then
( ( $+__p9k_force_term_shell_integration ) ) || typeset -gri __p9k_force_term_shell_integration = 1
fi
typeset -ga precmd_functions = ( ${ precmd_functions : #_p9k_precmd_first } )
}
@ -9303,6 +9483,7 @@ if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_p
zf_rm -f -- $__p9k_instant_prompt_dump_file { ,.zwc} 2>/dev/null
fi
typeset -g P9K_VERSION = 1.20.10
unset VSCODE_SHELL_INTEGRATION
_p9k_init_ssh