summaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-11-06 11:21:12 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-11-06 11:21:12 +0300
commit00c69d6bda183825376864b5ba40588bc84a85a8 (patch)
tree59cadb5399f9edad4bdfe8a852b061dbc6ef3fb2 /internal/p10k.zsh
parent4b34a6ed51285346360c42f32458c186f7331b25 (diff)
add POWERLEVEL9K_TRANSIENT_PROMPT
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh43
1 files changed, 38 insertions, 5 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 371186bc..e0a7b398 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -409,7 +409,7 @@ _p9k_translate_color() {
fi
}
-# _p9k_param prompt_foo_BAR BACKGROUND red
+# _p9k_color prompt_foo_BAR BACKGROUND red
_p9k_color() {
local key="_p9k_color ${(pj:\0:)*}"
_p9k_ret=$_p9k_cache[$key]
@@ -4079,20 +4079,28 @@ function _p9k_on_expand() {
__p9k_reset_state=1
if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE )); then
- _p9k__empty_line_i=3
if [[ $P9K_TTY == new ]]; then
+ _p9k__empty_line_i=3
_p9k__display_v[2]=hide
- else
+ elif [[ -z $_p9k_transient_prompt ]]; then
+ _p9k__empty_line_i=3
_p9k__display_v[2]=print
+ else
+ unset _p9k__empty_line_i
+ _p9k__display_v[2]=show
fi
fi
if (( _POWERLEVEL9K_SHOW_RULER )); then
- _p9k__ruler_i=3
if [[ $P9K_TTY == new ]]; then
+ _p9k__ruler_i=3
_p9k__display_v[4]=hide
- else
+ elif [[ -z $_p9k_transient_prompt ]]; then
+ _p9k__ruler_i=3
_p9k__display_v[4]=print
+ else
+ unset _p9k__ruler_i
+ _p9k__display_v[4]=show
fi
fi
@@ -4534,6 +4542,8 @@ _p9k_init_vars() {
typeset -g _p9k_uname
typeset -g _p9k_uname_o
typeset -g _p9k_uname_m
+ typeset -g _p9k_transient_prompt
+ typeset -g _p9k_last_prompt_pwd
typeset -gA _p9k__display_k
typeset -ga _p9k__display_v
@@ -4561,6 +4571,9 @@ _p9k_init_params() {
fi
fi
+ _p9k_declare -s POWERLEVEL9K_TRANSIENT_PROMPT off
+ [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == (off|always|same-dir) ]] || _POWERLEVEL9K_TRANSIENT_PROMPT=off
+
_p9k_declare -F POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS 5
_p9k_declare -i POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES 1
_p9k_declare -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS -- context dir vcs
@@ -4870,6 +4883,16 @@ function _p9k_zle_line_finish() {
__p9k_reset_state=0
fi
+ if [[ -n $_p9k_transient_prompt ]]; then
+ if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == always || $_p9k_pwd == $_p9k_last_prompt_pwd ]]; then
+ RPROMPT=
+ PROMPT=$_p9k_transient_prompt
+ reset=1
+ else
+ _p9k_last_prompt_pwd=$_p9k_pwd
+ fi
+ fi
+
if (( reset )); then
_p9k_reset_prompt
fi
@@ -5244,6 +5267,16 @@ function _p9k_init_cacheable() {
_p9k_init_params
_p9k_init_prompt
+ if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT != off ]]; then
+ _p9k_transient_prompt='%b%k%s%u%F{%(?.'
+ _p9k_color prompt_prompt_char_OK_VIINS FOREGROUND 76
+ _p9k_transient_prompt+=$_p9k_ret'.'
+ _p9k_color prompt_prompt_char_ERROR_VIINS FOREGROUND 196
+ _p9k_transient_prompt+=$_p9k_ret')}${${P9K_CONTENT::="❯"}+}'
+ _p9k_param prompt_prompt_char_OK_VIINS CONTENT_EXPANSION '${P9K_CONTENT}'
+ _p9k_transient_prompt+='${:-"'$_p9k_ret'"}%b%k%f%s%u '
+ fi
+
_p9k_uname="$(uname)"
[[ $_p9k_uname == Linux ]] && _p9k_uname_o="$(uname -o 2>/dev/null)"
_p9k_uname_m="$(uname -m)"