From e3beeea0ae8e2fdc5d997edeed4ffc3870b49bae Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 19 May 2020 10:10:43 +0200 Subject: [PATCH] block SIGINT in nested p10k calls; allow SIGINT in gitstatus_start --- internal/p10k.zsh | 36 ++++++++++++++++++++++++++---------- powerlevel10k.zsh-theme | 5 ++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 5a980a3e..025da391 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1,4 +1,4 @@ -if [[ $__p9k_sourced != 11 ]]; then +if [[ $__p9k_sourced != 12 ]]; then >&2 print -P "" >&2 print -P "[%F{1}ERROR%f]: Corrupted powerlevel10k installation." >&2 print -P "" @@ -7882,7 +7882,16 @@ _p9k_init_vcs() { _p9k_segment_in_use vcs || return _p9k_vcs_info_init if (( $+functions[_p9k_preinit] )); then - (( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )) && gitstatus_start_p9k_ POWERLEVEL9K + if (( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then + () { + trap 'return 130' INT + { + gitstatus_start_p9k_ POWERLEVEL9K + } always { + trap ':' INT + } + } + fi return 0 fi (( _POWERLEVEL9K_DISABLE_GITSTATUS )) && return @@ -7910,14 +7919,21 @@ _p9k_init_vcs() { -a POWERLEVEL9K }" source $gitstatus_dir/gitstatus.plugin.zsh _p9k_ || return - gitstatus_start_p9k_ \ - -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ - -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ - -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ - -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ - -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - ${${_POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS:#0}:+-e} \ - POWERLEVEL9K + () { + trap 'return 130' INT + { + gitstatus_start_p9k_ \ + -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ + -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ + -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ + -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ + -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ + ${${_POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS:#0}:+-e} \ + POWERLEVEL9K + } always { + trap ':' INT + } + } } _p9k_init() { diff --git a/powerlevel10k.zsh-theme b/powerlevel10k.zsh-theme index 419d7e28..cd49dd4c 100644 --- a/powerlevel10k.zsh-theme +++ b/powerlevel10k.zsh-theme @@ -23,8 +23,7 @@ # __p9k_trapint is to work around bugs in zsh: https://www.zsh.org/mla/workers/2020/msg00612.html. # Likewise for `trap ":"` instead of the plain `trap ""`. typeset -gr __p9k_intro_base='emulate -L zsh -o no_hist_expand -o extended_glob -o no_prompt_bang -o prompt_percent -o no_prompt_subst -o no_aliases -o no_bg_nice -o typeset_silent - trap ":" INT - trap "trap ${(q)__p9k_trapint:--} INT" EXIT + (( $+__p9k_trapped )) || { local -i __p9k_trapped; trap : INT; trap "trap ${(q)__p9k_trapint:--} INT" EXIT } local -a match mbegin mend local -i MBEGIN MEND OPTIND local MATCH OPTARG IFS=$'\'' \t\n\0'\' @@ -58,7 +57,7 @@ function _p9k_init_locale() { if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file ]] && (( ! $+functions[_p9k_preinit] )) && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then _p9k_preinit fi - typeset -gr __p9k_sourced=11 + typeset -gr __p9k_sourced=12 if [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]]; then if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus ]]; then local f