zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Tameling <tamelingdaniel@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: When RPROMPT != RPS1
Date: Fri, 23 Jun 2017 22:07:57 +0200	[thread overview]
Message-ID: <m237aqlb6q.fsf@Daniels-Air.fritz.box> (raw)
In-Reply-To: <20170622101735.4ebebd11@pwslap01u.europe.root.pri>


Peter Stephenson writes:

> On Wed, 21 Jun 2017 10:16:45 -0700
> Bart Schaefer <schaefer@brasslantern.com> wrote:
>> I don't have a good suggestion for how to satisfy both constraints.
>> Anyone?  The parameter initialization code has been broken up into
>> a few more sections already, maybe there's a way to rearrange these
>> as well.
>
> We can at least make it less likely people are going to trip over the
> complications if they're simply using the prompt system.
>
> pws

If I understand the problem correctly, the issue is not just limited to
the right prompts. The different themes set different prompt variables,
so when you change between themes you get a prompt setup that depends on
the history of themes you used.

For example, if I do

autoload -Uz promptinit; promptinit
prompt clint
echo $PS3

I get

?#

But if I do

autoload -Uz promptinit; promptinit
prompt adam1
prompt clint
echo $PS3

I get

%K{blue}%n@%m%k %B%F{green}%147<...<%~
%}%F{white} ?# %b%f%k

Interestingly, there is no problem with the prompt functions like
precmd, preexec etc. as the configuration of the previously active theme
gets deleted in set_prompt right before the new theme is activated:

local hook
for hook in chpwd precmd preexec periodic zshaddhistory zshexit; do
  add-zsh-hook -D "${hook}" "prompt_*_${hook}"
done

I think one solution for getting a consistent setup might be to add some
code at the same place that restores the prompt variables to their
default values.
Maybe something along the lines of what I included below (which seems to
solve the problem on my system). However, this breaks the bart theme as
it has a mode of operation where one can set the right prompt before
activating the theme.

Best,  
Daniel

diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit
index 587248997..0bc9b1ab4 100644
--- a/Functions/Prompts/promptinit
+++ b/Functions/Prompts/promptinit
@@ -160,6 +160,11 @@ Use prompt -h <theme> for help on specific themes.'
        for hook in chpwd precmd preexec periodic zshaddhistory zshexit; do
          add-zsh-hook -D "${hook}" "prompt_*_${hook}"
        done
+       PS1='%m%# '
+       PS2='%_> '
+       PS3='?# '
+       PS4='+%N:%i> '
+       unset RPROMPT RPS1 RPROMPT2 RPS2
        typeset -ga zle_highlight=( ${zle_highlight:#default:*} )
        (( ${#zle_highlight} )) || unset zle_highlight


  reply	other threads:[~2017-06-23 20:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 17:08 Jim
2017-06-20 18:22 ` Jim
2017-06-21 17:16   ` Bart Schaefer
2017-06-22  9:17     ` Peter Stephenson
2017-06-23 20:07       ` Daniel Tameling [this message]
2017-06-24  3:37         ` Bart Schaefer
2017-06-24 20:09           ` Daniel Tameling
2017-07-28  2:53             ` Bart Schaefer
2017-07-31 16:24               ` Jim
2017-07-31 18:33                 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m237aqlb6q.fsf@Daniels-Air.fritz.box \
    --to=tamelingdaniel@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).