From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, MPART_ALT_DIFF_COUNT,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22163 invoked from network); 16 Apr 2021 22:35:49 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 Apr 2021 22:35:49 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1618612549; b=QZswQkE30nHlUuXjn8j+XipCbY/RPQl66mzS+BFqqHOJiZf0F8/YbUu6D5k71FCCJY5jllqqsk s6m5oq77I9U9A56ljt8NY7eX49BHE9hXMXWslLkMRBtoMhWEYryHBGFLoSSMEwxKC3TmxzNZt1 Vr0yYKsTmbf+mjceEGL//AfmIxRxUH23lSU3m3xRWrpOwKIhvA0vRVUuak1+YjfecssW7/4cYB T3SaBPtinNaUpXOKMoeU4IU76mFsw6pg/nHzuY88KcqCP8moblrPhOVF7vHs/w+FGrjRs5MvxI SJDRmwCf6fPZTEpk9oDZtS75lcs8oT1bXBHyJePb2s2NDQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f176.google.com) smtp.remote-ip=209.85.208.176; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1618612549; bh=PTeXsxeZUEPMhIQ6a4N3D1lcsB70Q2AQaWe6E2jjfMU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:References:To:Cc:In-Reply-To:Date:Subject:MIME-Version: Content-Type:Message-ID:From:DKIM-Signature:DKIM-Signature; b=MydsVahOkNvWBMuD8Dob6zie6DilBEGLNyJEYwzvs9yJTY9MToI4w7GIqsRlVXg3HIEf1G8iSc VICgW9bgXPhIQxBPjagB4yPpLP3LMFF2CNOA0rEneN4Wa7f7DnK9TKoBihIv0dsDWCOUVTWKNH xivvCy/tVKcilK09bP6i84egOBi6LEE1hL9NsRMYoG4SAtVhWsONtQ27d6oixoWWkwVo9Npjxr YKkP5Jk2kEVnihN889+KwPY45h5TFi+/XbgxphCbX9iq3efx9rTZSy4Llm1XqdTuSRm2xWeZPJ koJoum7zI8wgNvNQtQY8F9XktLiNRaR2Eap/WsKyl3dp3w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:References:To:Cc:In-Reply-To:Date: Subject:Mime-Version:Content-Type:Message-Id:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Td2pTB4h+Aw1UjeVCAbrMUsh/zFbaH8aH6IdNuszAeA=; b=AlXDiuXttyAfSt/5KbDlJgPM8e 2H6Kc4FwsbSi+EYV9l0omq4tzzwMtKes2zNQCrZUu8+eVAoFZJ4N2mxDqzcOW8uEhH6oTbGydqDSi BmSn2v6l0INcbr4jOKDWzzs3WtNIECA767pAwa9KhaJzK0YZJXbK0HWN0zAXLJqNv3/xhNYeqLPvK XXSvYwdgp3TKhalP3xwsE1301ySuqaEK/i+2xvauj3OppktwoK/Ew1xyKilIsgdynk+H51pdvyHmc XosRKSx1V2OpB3XqGShUCNKGH8qrbUWl4T4PaIWAPg7yT1B4nW25J+w4yGow0Mq3OL8x7wtb4uzKF kWRifsLg==; Received: from authenticated user by zero.zsh.org with local id 1lXX40-000NaU-BH; Fri, 16 Apr 2021 22:35:48 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f176.google.com) smtp.remote-ip=209.85.208.176; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f176.google.com ([209.85.208.176]:40941) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lXX3F-000NLO-TO; Fri, 16 Apr 2021 22:35:03 +0000 Received: by mail-lj1-f176.google.com with SMTP id c1so24428724ljd.7 for ; Fri, 16 Apr 2021 15:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=Td2pTB4h+Aw1UjeVCAbrMUsh/zFbaH8aH6IdNuszAeA=; b=E2IOq3EMAgvAPCL0foRRXqVmJf9xqloiDzCJpJkq8qlWx3gWq5L5mC18yeCI4RS39I ilZ7rtVIpdU6+ueRQHaVUgRLoGCTebkwbrUuT0772FhAz5KTQWtwVk8B0F69HOU2I2/8 3YXoc4rUhVwcsqry2woLcqyJ26mOZAHJ7tgUNn4JHyiy5EsZu0HZVfiHiMmv3jgF5fWr dBvUuPoaYgYtsegGdSuGOhZwUpHP3Lkyo0HYCSkgLNuQY8ESIzTkzRWPs7bRMxdKzz8Q vGSXKe/ovJe9qImFtcqzz3Rps8njJQ6aQ3HKowA9f08fiA13WHPQ8hQCjF2aHD0D89Gp k79w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=Td2pTB4h+Aw1UjeVCAbrMUsh/zFbaH8aH6IdNuszAeA=; b=mNg8T9gUluIPwVcjG2EbehcDWOVkpL+dEmAf0gkhaybs0Ie/fqy52N/HIxccwMUxTf 3+jJKN3zO/WT4iUpsSnJaJBW0OgUqvu0SyKN9vT05Nj2Z4PxvriDqz1t1s8g6MaL8zbq NzTFlRqAgGGaZFHZlVp4ryyoVUVxurioUuBC7yirwXXOLz0cQKU4ZnT8YkPwhJbb6vZL pANnfCbHJnGdazKv4jGJ99gJ8eUORKhkq+S6umhQcstxCmsIG/EYwTGpcIw4BBpRxRzb l1BGD0F1aTY5A1GgtANb0TjjlzAxqJtNcMnxDAkKD/9sYVhqSPhh3svcQZkx7xq+TgcK /MNA== X-Gm-Message-State: AOAM533yswyIkiWNzFjyVaKfnku4Qd0O0e9boA55J27/sXcacjSGGhOA dnd+1ShPNfIL2oRDAGnWkq9+Ervr3BUzvw== X-Google-Smtp-Source: ABdhPJyV+fTt2ttJtvRURPKhF1d3V94Leq+FVWR1g5Rs9Iz9xdQQxgijzGJJCRwwMVZO9ApA09hSag== X-Received: by 2002:a2e:8396:: with SMTP id x22mr3772191ljg.247.1618612500937; Fri, 16 Apr 2021 15:35:00 -0700 (PDT) Received: from [192.168.1.15] (hag-tkubng22-50df3e-132.dhcp.inet.fi. [80.223.62.132]) by smtp.gmail.com with ESMTPSA id p9sm1107791lfu.224.2021.04.16.15.35.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Apr 2021 15:35:00 -0700 (PDT) From: Marlon Richert Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_545B51A3-C3A6-4B5F-978C-63A320E05AFE" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: [RFC][PATCH] Reset ZLE hooks when changing prompt themes (was Re: [RFC][PATCH] `newuser` prompt theme) Date: Sat, 17 Apr 2021 01:34:57 +0300 In-Reply-To: <20210415213456.GE6669@tarpaulin.shahaf.local2> Cc: Zsh hackers list To: Daniel Shahaf References: <7E71FA83-356E-448B-9726-02DF3FF5BD14@gmail.com> <873D08A9-F321-474A-8440-CCE7DCCBA529@gmail.com> <20210414120551.GA3882@tarpaulin.shahaf.local2> <20210415213456.GE6669@tarpaulin.shahaf.local2> X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Seq: 48609 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: --Apple-Mail=_545B51A3-C3A6-4B5F-978C-63A320E05AFE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 16 Apr 2021, at 00:34, Daniel Shahaf wrote: > Marlon wrote on Thu, Apr 15, 2021 at 21:54:48 +0300: >> +that follow the naming pattern tt(prompt__) are = automatically >=20 > This should be tt(prompt_)var(theme)tt(_)var(hook). >=20 >> +removed when the prompt theme changes or is disabled. >=20 > Add a pointer to the relevant section? Something like > . > ifzman(=E2=80=A6 Manipulating Hook Functions =E2=80=A6 = above)ifnzman(noderef(Manipulating Hook Functions)) > . > plus appropriate markup in the first branch. Done and done. >> - for hook in chpwd precmd preexec periodic zshaddhistory = zshexit; do >> - add-zsh-hook -D "${hook}" "prompt_*_${hook}" >> + for hook in chpwd precmd preexec periodic zshaddhistory = zshexit \ >> + zsh_directory_name; do >> + add-zsh-hook -D "$hook" "prompt_*_$hook" >> + done >> + for hook in isearch-exit isearch-update line-pre-redraw = line-init \ >> + line-finish history-line-set keymap-select; do >> + add-zle-hook-widget -D "$hook" "prompt_*_$hook" > Hmm. I'm not at all sure that this is sufficient. There's a bunch of > reference to precmd and preexec in promptinit; it's possible that some > of these should also handle chpwd,periodic,zshaddhistory,zshexit > (a pre=C3=ABxisting issue) and the add-zle-hook-widget hook classes = (an issue > this patch might be introducing). Attached is a new version of the patch that handles _all the things._ = \o/ --Apple-Mail=_545B51A3-C3A6-4B5F-978C-63A320E05AFE Content-Type: multipart/mixed; boundary="Apple-Mail=_CD3F63F7-1B91-4EBC-BD48-1D2EA28F14CB" --Apple-Mail=_CD3F63F7-1B91-4EBC-BD48-1D2EA28F14CB Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 On = 16 Apr 2021, at 00:34, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
Marlon wrote = on Thu, Apr 15, 2021 at 21:54:48 +0300:
+that follow the naming pattern = tt(prompt_<theme>_<hook>) are automatically

This should be tt(prompt_)var(theme)tt(_)var(hook).

+removed when the prompt theme changes or is disabled.

Add a pointer to the relevant section?  Something = like
.
   ifzman(=E2=80=A6 Manipulating Hook = Functions =E2=80=A6 above)ifnzman(noderef(Manipulating Hook = Functions))
.
plus = appropriate markup in the first branch.

Done and done.


- =       for hook in chpwd precmd preexec = periodic zshaddhistory zshexit; do
- =         add-zsh-hook -D = "${hook}" "prompt_*_${hook}"
+ =       for hook in chpwd precmd preexec = periodic zshaddhistory zshexit \
+ =           zsh_directory_= name; do
+ =         add-zsh-hook -D "$hook" = "prompt_*_$hook"
+ =       done
+ =       for hook in isearch-exit = isearch-update line-pre-redraw line-init \
+ =           line-finish = history-line-set keymap-select; do
+ =         add-zle-hook-widget -D = "$hook" "prompt_*_$hook"
Hmm.  I'm not at all sure that this is sufficient. =  There's a bunch of
reference to precmd and preexec in promptinit; it's possible = that some
of these = should also handle chpwd,periodic,zshaddhistory,zshexit
(a = pre=C3=ABxisting issue) and the add-zle-hook-widget hook classes (an = issue
this patch = might be introducing).

Attached is a new version of the patch = that handles _all the things._ \o/

= --Apple-Mail=_CD3F63F7-1B91-4EBC-BD48-1D2EA28F14CB Content-Disposition: attachment; filename=0001-Reset-ZLE-hooks-when-changing-prompt-themes.txt Content-Type: text/plain; x-unix-mode=0644; name="0001-Reset-ZLE-hooks-when-changing-prompt-themes.txt" Content-Transfer-Encoding: quoted-printable =46rom ae73759d82da603e6e88e1a95d91274451defc91 Mon Sep 17 00:00:00 2001 From: Marlon Richert Date: Fri, 16 Apr 2021 23:00:44 +0300 Subject: [PATCH] Reset ZLE hooks when changing prompt themes --- Doc/Zsh/contrib.yo | 10 ++- Functions/Prompts/promptinit | 167 +++++++++++++++-------------------- 2 files changed, 79 insertions(+), 98 deletions(-) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 3c4fdded0..6e33cd6f9 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2032,10 +2032,12 @@ setopts (tt(promptbang), etc.) are turned on, = all other prompt-related options are turned off. The tt(prompt_opts) array preserves setopts = even beyond the scope of tt(localoptions), should your function need that. ) -item(Modify precmd and preexec)( -Use of tt(add-zsh-hook) is recommended. The tt(precmd) and tt(preexec) -hooks are automatically adjusted if the prompt theme changes or is -disabled. +item(Modify hooks)( +Use of tt(add-zsh-hook) and tt(add-zle-hook-widget) is recommended (see +ifzman(the bf(Manipulating Hook Functions) section above)\ +ifnzman(noderef(Manipulating Hook Functions))\ +). All hooks that follow the naming pattern = tt(prompt_)var(theme)tt(_)var(hook) +are automatically removed when the prompt theme changes or is disabled. ) item(Declare cleanup)( If your function makes any other changes that should be undone when the diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit index 37d69f100..a6c9e31dd 100644 --- a/Functions/Prompts/promptinit +++ b/Functions/Prompts/promptinit @@ -14,6 +14,8 @@ prompt_themes=3D() promptinit () { emulate -L zsh setopt extendedglob + autoload -Uz add-zsh-hook add-zle-hook-widget + local ppath=3D'' name theme local -a match mbegin mend =20 @@ -32,9 +34,6 @@ promptinit () { fi done =20 - # To manipulate precmd and preexec hooks... - autoload -Uz add-zsh-hook - # Variables common to all prompt styles prompt_newline=3D$'\n%{\r%}' } @@ -47,38 +46,23 @@ prompt_preview_safely() { return fi =20 - # This handles all the stuff from the default :prompt-theme restore - local +h PS1=3D$PS1 PS2=3D$PS2 PS3=3D$PS3 PS4=3D$PS4 RPS1=3D$RPS1 = RPS2=3D$RPS2 - local +h PROMPT=3D$PROMPT RPROMPT=3D$RPROMPT RPROMPT2=3D$RPROMPT2 = PSVAR=3D$PSVAR - local -a precmd_functions preexec_functions prompt_preview_restore - local -aLl +h zle_highlight + # Run this in a subshell, so we don't need to clean up afterwards. + ( + # Execute current theme's cleanup sequence, if any. + zstyle -t :prompt-theme cleanup =20 - { - # Save and clear current restore-point if any - zstyle -g prompt_preview_restore :prompt-theme restore - { - zstyle -d :prompt-theme restore - # Execute current cleanup sequence, if any. - zstyle -t :prompt-theme cleanup - - # The next line is a bit ugly. It (perhaps unnecessarily) - # runs the prompt theme setup function to ensure that if - # the theme has a _preview function that it's been autoloaded. + # If we can't find a _preview function, run the _setup function to = see if + # it will create one. + typeset +f prompt_${1}_preview >&/dev/null || prompt_${1}_setup =20 - if typeset +f prompt_${1}_preview >&/dev/null; then - prompt_${1}_preview "$@[2,-1]" - else - prompt_preview_theme "$@" - fi - } always { - # Run any theme-specific cleanup, then reset restore point - zstyle -t :prompt-theme cleanup - } - } always { - (( $#prompt_preview_restore )) && - zstyle -e :prompt-theme restore "${prompt_preview_restore[@]}" - } + # ...then try again. + if typeset +f prompt_${1}_preview >&/dev/null; then + prompt_${1}_preview "$@[2,-1]" + else + prompt_preview_theme "$@" + fi + ) } =20 set_prompt() { @@ -97,21 +81,6 @@ Options: Use prompt -h for help on specific themes.' =20 getopts "chlps:" opt - case "$opt" in - (h|p) - setopt localtraps - if [[ -z "$prompt_theme[1]" ]]; then - # Not using a prompt theme; save settings - local +h PS1=3D$PS1 PS2=3D$PS2 PS3=3D$PS3 PS4=3D$PS4 RPS1=3D$RPS1= RPS2=3D$RPS2 - local +h PROMPT=3D$PROMPT RPROMPT=3D$RPROMPT RPROMPT2=3D$RPROMPT2= PSVAR=3D$PSVAR - local -a precmd_functions preexec_functions - local theme_reset=3D'' - else - local theme_reset=3D'prompt_${prompt_theme[1]}_setup = "${(@)prompt_theme[2,-1]}"' - fi - trap 'zstyle -t :prompt-theme cleanup;'"${theme_reset:+ = $theme_reset}" 0 - ;; - esac case "$opt" in c) if [[ -n $prompt_theme ]]; then print -n "Current prompt theme" @@ -123,21 +92,26 @@ Use prompt -h for help on specific themes.' return ;; h) if [[ -n "$2" && -n $prompt_themes[(r)$2] ]]; then - if functions prompt_$2_setup >/dev/null; then + # Run this in a subshell, so we don't need to clean up = afterwards. + ( + # Execute current theme's cleanup sequence, if any. zstyle -t :prompt-theme cleanup - # The next line is a bit ugly. It (perhaps unnecessarily) - # runs the prompt theme setup function to ensure that if - # the theme has a _help function that it's been autoloaded. - prompt_$2_setup - fi - if functions prompt_$2_help >/dev/null; then - print "Help for $2 theme:\n" - prompt_$2_help - else - print "No help available for $2 theme." - fi - print "\nType \`prompt -p $2' to preview the theme, \`prompt = $2'" - print "to try it out, and \`prompt -s $2' to use it in future = sessions." + + # If we can't find a _help function, run the _setup function = to see + # if it will create one. + typeset +f prompt_$2_help >/dev/null || + prompt_$2_setup + + # ...then try again. + if typeset +f prompt_$2_help >/dev/null; then + print "Help for $2 theme:\n" + prompt_$2_help + else + print "No help available for $2 theme." + fi + print "\nType \`prompt -p $2' to preview the theme, \`prompt = $2'" + print "to try it out, and \`prompt -s $2' to use it in = future sessions." + ) else print "$usage" fi @@ -178,8 +152,13 @@ Use prompt -h for help on specific themes.' =20 # Reset some commonly altered bits to the default local hook - for hook in chpwd precmd preexec periodic zshaddhistory zshexit; = do - add-zsh-hook -D "${hook}" "prompt_*_${hook}" + for hook in chpwd precmd preexec periodic zshaddhistory zshexit = \ + zsh_directory_name; do + add-zsh-hook -D "$hook" "prompt_*_$hook" + done + for hook in isearch-exit isearch-update line-pre-redraw = line-init \ + line-finish history-line-set keymap-select; do + add-zle-hook-widget -D "$hook" "prompt_*_$hook" done typeset -ga zle_highlight=3D( ${zle_highlight:#default:*} ) (( ${#zle_highlight} )) || unset zle_highlight @@ -192,11 +171,8 @@ Use prompt -h for help on specific themes.' =20 prompt_cleanup () { local -a cleanup_hooks theme_active - if ! zstyle -g cleanup_hooks :prompt-theme cleanup - then - (( $+prompt_preview_restore =3D=3D 0 )) && - if ! zstyle -g theme_active :prompt-theme restore - then + if ! zstyle -g cleanup_hooks :prompt-theme cleanup; then + if ! zstyle -g theme_active :prompt-theme restore; then print -u2 "prompt_cleanup: no prompt theme active" return 1 fi @@ -225,22 +201,23 @@ prompt () { [[ -o promptpercent ]] && prompt_opts+=3D(percent) [[ -o promptsp ]] && prompt_opts+=3D(sp) [[ -o promptsubst ]] && prompt_opts+=3D(subst) - zstyle -e :prompt-theme restore \ - 'zstyle -d :prompt-theme restore;' \ - 'prompt_default_setup;' \ - ${PS1+PS1=3D"${(q)PS1}"} \ - ${PS2+PS2=3D"${(q)PS2}"} \ - ${PS3+PS3=3D"${(q)PS3}"} \ - ${PS4+PS4=3D"${(q)PS4}"} \ - ${RPS1+RPS1=3D"${(q)RPS1}"} \ - ${RPS2+RPS2=3D"${(q)RPS2}"} \ - ${RPROMPT+RPROMPT=3D"${(q)RPROMPT}"} \ - ${RPROMPT2+RPROMPT2=3D"${(q)RPROMPT2}"} \ - ${PSVAR+PSVAR=3D"${(q)PSVAR}"} \ - "precmd_functions=3D(${(q)precmd_functions[@]})" \ - "preexec_functions=3D(${(q)preexec_functions[@]})" \ - "prompt_opts=3D( ${prompt_opts[*]} )" \ - 'reply=3D(yes)' + zstyle -e :prompt-theme restore " + zstyle -d :prompt-theme restore + prompt_default_setup + ${PS1+PS1=3D${(q+)PS1}} + ${PS2+PS2=3D${(q+)PS2}} + ${PS3+PS3=3D${(q+)PS3}} + ${PS4+PS4=3D${(q+)PS4}} + ${RPS1+RPS1=3D${(q+)RPS1}} + ${RPS2+RPS2=3D${(q+)RPS2}} + ${RPROMPT+RPROMPT=3D${(q+)RPROMPT}} + ${RPROMPT2+RPROMPT2=3D${(q+)RPROMPT2}} + ${PSVAR+PSVAR=3D${(q+)PSVAR}} + $( add-zsh-hook -L ) + $( add-zle-hook-widget -L ) + prompt_opts=3D( $prompt_opts[*] ) + reply=3D( yes ) + " } set_prompt "$@" =20 @@ -253,12 +230,6 @@ prompt () { prompt_preview_theme () { emulate -L zsh =20 - # Check for proper state handling - (( $+prompt_preview_restore )) || { - prompt_preview_safely "$@" - return - } - # Minimal preview for prompts that don't supply one local -a prompt_opts print -n "$1 theme" @@ -268,12 +239,20 @@ prompt_preview_theme () { prompt_${1}_setup "$@[2,-1]" (( ${#prompt_opts} )) && setopt noprompt{bang,cr,percent,sp,subst} = "prompt${^prompt_opts[@]}" + + [[ -n ${chpwd_functions[(r)prompt_${1}_chpwd]} ]] && + prompt_${1}_chpwd [[ -n ${precmd_functions[(r)prompt_${1}_precmd]} ]] && - prompt_${1}_precmd - [[ -o promptcr ]] && print -n $'\r'; : - print -P "${PS1}command arg1 arg2 ... argn" + prompt_${1}_precmd + + # We'd like to call zle-line-init/finish hooks, too, but that's not = possible + # while the ZLE is not active. + + [[ -o promptcr ]] && print -n $'\r' + :; print -P -- "${PS1}command arg1 arg2 ... argn" + [[ -n ${preexec_functions[(r)prompt_${1}_preexec]} ]] && - prompt_${1}_preexec + prompt_${1}_preexec } =20 [[ -o kshautoload ]] || promptinit "$@" --=20 2.31.1 --Apple-Mail=_CD3F63F7-1B91-4EBC-BD48-1D2EA28F14CB Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii


--Apple-Mail=_CD3F63F7-1B91-4EBC-BD48-1D2EA28F14CB-- --Apple-Mail=_545B51A3-C3A6-4B5F-978C-63A320E05AFE--