Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Weird reset-prompt behavior
- X-seq: zsh-users 13157
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Weird reset-prompt behavior
- Date: Sun, 24 Aug 2008 14:58:49 -0700
- In-reply-to: <200808232249.13582.raichoo@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200808232249.13582.raichoo@xxxxxxxxxxxxxx>
On Aug 23, 10:49pm, Björn wrote:
} Subject: Weird reset-prompt behavior
}
} I'm pretty new to zsh so i don't know if this is already known, but i
} discovered a pretty weird behavior when resetting the prompt and rprompt
To address your specific problem, you shouldn't need zle-line-init at
all for this. The editor always starts in the same state with the
viins keymap, so just set up PROMPT and RPROMPT in your precmd and let
zle-keymap-select do all the rest of the work.
However, your example does point out a bit of odd behavior. Ignoring
zle-keymap-select for the moment, try the following in a new shell.
torch% n=0
torch% zle-line-init() { RPS1=$[n++]; zle reset-prompt }
torch% zle -N zle-line-init
torch%
Hmm. Why didn't the right prompt appear when the new left prompt was
printed after creating the widget? It gets stranger, though; enter
a command, such as "print $n" (using a 40-column terminal below so as
to avoid line-wrapping) ...
torch% print $n
1
torch% 0
Well, OK, n=1 and RPS1=0, which is sort of as expected. But now it gets
really strange. Begin typing anything (I started to type "print" again
in the cut-and-paste below):
torch% p 1
RPS1 just belatedly updated itself! I'm pretty sure zle-line-init was
not called again here, so there's some kind of delayed reaction (the
$[n++] did happen when the widget was created, but the display was
never updated). Further demonstration, again starting fresh:
torch% zle-line-init() {
function> zle -R $SECONDS
function> PS1="$SECONDS %# "
function> zle reset-prompt
function> }
torch% zle -N zle-line-init
torch%
42
Now start to type anything, and the screen suddenly looks like this:
torch% zle-line-init() {
function> zle -R $SECONDS
function> PS1="$SECONDS %# "
function> zle reset-prompt
function> }
torch% zle -N zle-line-init
42 % p
Note the "torch%" prompt has been updated and the "zle -R" output has
been erased. (Things are even stranger if I used "zle -M" instead,
but leave that aside for now.) Proceeding ...
function> }
torch% zle -N zle-line-init
42 % print $SECONDS
156
42 %
156
This proves that zle-line-init ran when the editor started, but that
Again start to type ...
42 % print $SECONDS
156
156 % p
I almost suspect this is just a matter of a fflush() that hasn't yet
happened, except for that $[n++] oddity in the very first example.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author