mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-25 13:30:07 +00:00
wip: some churn on dynamic stuff
This commit is contained in:
parent
1b2990ecb3
commit
d9c587a8d7
2 changed files with 56 additions and 56 deletions
31
dynamic.txt
31
dynamic.txt
|
@ -47,12 +47,29 @@ POWERLEVEL9K_DISPLAY_NEW_TTY=(ruler=hide)
|
||||||
POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS=5
|
POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS=5
|
||||||
POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=true
|
POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=true
|
||||||
|
|
||||||
# $BUFFER current buffer
|
# $BUFFER current command line
|
||||||
# $1 the first word in $BUFFER after alias expansion
|
# $P9K_COMMAND the first word in $BUFFER after alias expansion
|
||||||
function p10k-on-buffer-change() {
|
function p10k-on-buffer-change() {
|
||||||
if [[ $2 == (|*/)kubectl ]]; then
|
case ${P9K_COMMAND:t} in
|
||||||
p10k display segment:kubecontext=show
|
kubectl) p10k display segment:kubecontext=show;;
|
||||||
else
|
az) p10k display segment:azure=show;;
|
||||||
p10k display segment:kubecontext=hide
|
terraform) p10k display segment:azure=show segment:kubecontext=show;;
|
||||||
fi
|
*) p10k display segment:azure=hide segment:kubecontext=hide;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# $P9K_PROMPT_TYPE instant|regular
|
||||||
|
# $P9K_TTY_TYPE new|old
|
||||||
|
function p10k-on-pre-prompt() {
|
||||||
|
p10k display segment:kubecontext=hide segment:azure=hide
|
||||||
|
p10k display line1=show right=show segment:time=hide
|
||||||
|
if [[ $P9K_TTY_TYPE == new ]]; then
|
||||||
|
p10k display empty_line=hide
|
||||||
|
else
|
||||||
|
p10k display empty_line=show
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function p10k-on-post-prompt() {
|
||||||
|
p10k display line1=hide right=hide segment:time=show
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,7 +616,7 @@ _p9k_left_prompt_segment() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
p+="\${_p9k_c::=$content_exp_}"
|
p+="\${_p9k_c::=$content_exp_}"
|
||||||
p+='${_p9k_e::=${${__p9k_s_'${${1#prompt_}%%[A-Z_]#}'+00}:-'
|
p+='${_p9k_e::=${${${__p9k_display[s/'${${1#prompt_}%%[A-Z_]#}']:#show}:+00}:-'
|
||||||
if (( has_icon == -1 )); then
|
if (( has_icon == -1 )); then
|
||||||
p+='${${(%):-$_p9k_c%1(l.1.0)}[-1]}${${(%):-$_p9k_v%1(l.1.0)}[-1]}}'
|
p+='${${(%):-$_p9k_c%1(l.1.0)}[-1]}${${(%):-$_p9k_v%1(l.1.0)}[-1]}}'
|
||||||
else
|
else
|
||||||
|
@ -837,7 +837,7 @@ _p9k_right_prompt_segment() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
p+="\${_p9k_c::=$content_exp_}"
|
p+="\${_p9k_c::=$content_exp_}"
|
||||||
p+='${_p9k_e::=${${__p9k_s_'${${1#prompt_}%%[A-Z_]#}'+00}:-'
|
p+='${_p9k_e::=${${${__p9k_display[s/'${${1#prompt_}%%[A-Z_]#}']:#show}:+00}:-'
|
||||||
if (( has_icon == -1 )); then
|
if (( has_icon == -1 )); then
|
||||||
p+='${${(%):-$_p9k_c%1(l.1.0)}[-1]}${${(%):-$_p9k_v%1(l.1.0)}[-1]}}'
|
p+='${${(%):-$_p9k_c%1(l.1.0)}[-1]}${${(%):-$_p9k_v%1(l.1.0)}[-1]}}'
|
||||||
else
|
else
|
||||||
|
@ -3587,6 +3587,7 @@ _p9k_dump_instant_prompt() {
|
||||||
>&$fd print -r -- '
|
>&$fd print -r -- '
|
||||||
zmodload zsh/terminfo
|
zmodload zsh/terminfo
|
||||||
(( $+terminfo[cuu] && $+terminfo[cuf] && $+terminfo[ed] && $+terminfo[sc] && $+terminfo[rc] )) || return
|
(( $+terminfo[cuu] && $+terminfo[cuf] && $+terminfo[ed] && $+terminfo[sc] && $+terminfo[rc] )) || return
|
||||||
|
local -A __p9k_display
|
||||||
local pwd=${(%):-%/}
|
local pwd=${(%):-%/}
|
||||||
local prompt_file=$prompt_dir/prompt-${#pwd}
|
local prompt_file=$prompt_dir/prompt-${#pwd}
|
||||||
local key=$pwd:$ssh:${(%):-%#}
|
local key=$pwd:$ssh:${(%):-%#}
|
||||||
|
@ -5538,6 +5539,11 @@ Example: Bind Ctrl+P to toggle right prompt.
|
||||||
zle -N toggle-right-prompt
|
zle -N toggle-right-prompt
|
||||||
bindkey '^P' toggle-right-prompt"
|
bindkey '^P' toggle-right-prompt"
|
||||||
|
|
||||||
|
# 0 -- reset-prompt not blocked
|
||||||
|
# 1 -- reset-prompt blocked and not needed
|
||||||
|
# 2 -- reset-prompt blocked and needed
|
||||||
|
typeset -gi __p9k_reset_state
|
||||||
|
|
||||||
function p10k() {
|
function p10k() {
|
||||||
[[ $# != 1 || $1 != finalize ]] || { p10k-instant-prompt-finalize; return }
|
[[ $# != 1 || $1 != finalize ]] || { p10k-instant-prompt-finalize; return }
|
||||||
|
|
||||||
|
@ -5593,57 +5599,34 @@ function p10k() {
|
||||||
print -rP -- $__p9k_p10k_display_usage >&2
|
print -rP -- $__p9k_p10k_display_usage >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
if [[ $2 == -h ]]; then
|
||||||
|
print -rP -- $__p9k_p10k_display_usage >&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
local opt
|
local opt
|
||||||
local -i reset
|
|
||||||
for opt; do
|
for opt; do
|
||||||
case $opt in
|
local pair=(${(s:=:)opt})
|
||||||
-h) print -rP -- $__p9k_p10k_display_usage >&2; return 0;;
|
local name=${pair[1]/#segment/s}
|
||||||
+right)
|
local prev=$__p9k_display[$name]
|
||||||
if (( $+__p9k_x_right )); then
|
if [[ $pair[2] == *,* ]]; then # branch purely for optimization
|
||||||
reset=1
|
local list=(${(s:,:)${pair[2]}})
|
||||||
unset __p9k_x_right __p9k_x_gap
|
local new=${list[list[(I)cur]+1]:-$list[1]}
|
||||||
fi
|
else
|
||||||
;;
|
local new=$pair[2]
|
||||||
-right)
|
fi
|
||||||
if (( ! $+__p9k_x_right )); then
|
[[ $prev == $new ]] && continue
|
||||||
reset=1
|
__p9k_display[$name]=$new
|
||||||
__p9k_x_gap=
|
if (( __p9k_reset_state > 0 )); then
|
||||||
__p9k_x_right=
|
__p9k_reset_state=2
|
||||||
fi
|
else
|
||||||
;;
|
__p9k_reset_state=-1
|
||||||
right)
|
fi
|
||||||
reset=1
|
|
||||||
if (( $+__p9k_x_right )); then
|
|
||||||
unset __p9k_x_right __p9k_x_gap
|
|
||||||
else
|
|
||||||
typeset -g __p9k_x_right=
|
|
||||||
typeset -g __p9k_x_gap=
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
+s:*)
|
|
||||||
if (( $+parameters[__p9k_s_${opt:3 }] )); then
|
|
||||||
reset=1
|
|
||||||
unset __p9k_s_${opt:3 }
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
-s:*)
|
|
||||||
if (( ! $+parameters[__p9k_s_${opt:3 }] )); then
|
|
||||||
reset=1
|
|
||||||
typeset -g __p9k_s_${opt:3 }=
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
s:*)
|
|
||||||
reset=1
|
|
||||||
if (( $+parameters[__p9k_s_${opt:2 }] )); then
|
|
||||||
unset __p9k_s_${opt:2 }
|
|
||||||
else
|
|
||||||
typeset -g __p9k_s_${opt:2 }=
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
(( reset )) && zle && _p9k_reset_prompt || true
|
if (( __p9k_reset_state == -1 )); then
|
||||||
|
_p9k_reset_prompt
|
||||||
|
__p9k_reset_state=0
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
configure)
|
configure)
|
||||||
if (( ARGC > 1 )); then
|
if (( ARGC > 1 )); then
|
||||||
|
|
Loading…
Reference in a new issue