Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Append cancelled commands to history
- X-seq: zsh-users 14953
- From: "Nadav Har'El" <nyh@xxxxxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Append cancelled commands to history
- Date: Mon, 22 Mar 2010 10:42:26 +0200
- Cc: zsh-users@xxxxxxx
- Hebrew-date: 7 Nisan 5770
- In-reply-to: <100320105027.ZM20067@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <c16a574a0809181450t61a5b5ddq2e80797fde37636e@xxxxxxxxxxxxxx> <20080919162045.GA22435@xxxxxxxxxxxx> <20090706151644.6BF508027106@xxxxxxxxxxxxxxxxxx> <20090706154309.GA15663@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20090706155337.GB15663@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20100315164237.GA23224@xxxxxxxxxxxxxxxxxxxxxxxxxx> <100320105027.ZM20067@xxxxxxxxxxxxxxxxxxxxxx>
On Sat, Mar 20, 2010, Bart Schaefer wrote about "Re: Append cancelled commands to history":
> > I thought this would be simple - just replace the print line with
> > print -s -r -- "$PREBUFFER$BUFFER"
>
> Hmm. When I use TRAPINT, $PREBUFFER is always empty.
>
> torch% print $ZSH_VERSION $ZSH_PATCHLEVEL
> 4.3.10-dev-1 1.4940
Thanks for the explanations. For me, $PREBUFFER does work:
$ print $ZSH_VERSION $ZSH_PATCHLEVEL
4.3.10 1.4705
$ cat /etc/redhat-release; rpm -qf =zsh
Fedora release 12 (Constantine)
zsh-4.3.10-4.fc12.x86_64
$ functions TRAPINT
TRAPINT () {
zle && [[ $HISTNO -eq $HISTCMD ]] && print -s -r -- "$PREBUFFER$BUFFER"
echo "prebuffer: '$PREBUFFER'"
return $1
}
$ for i in *
for> do
for> echo<INTERRUPT>prebuffer: 'for i in *
do
'
$
But the problem I have now is that when I now go up in the history, the
last command I see is
for i in *
do
which is what standard zsh saved - without the last partial line - and when I
go up another command in history I see
for i in *
do
echo
which is what my code saved. I wished there was a way not to save that
shorter version, with only the accepted lines.
Of course, it's not so terrible as it is - I just wondered if there's a
way to do it better. Usually when I interrupt a multi-line command entry,
it's not because I'm not pleased with the last line I typed (if this was
the case, I could have just backspaced...), but rather, I'm not pleased
with the whole thing. So I want to save the whole thing (including the
last line I'm editing), and go to edit it later if I wish.
--
Nadav Har'El | Monday, Mar 22 2010, 7 Nisan 5770
nyh@xxxxxxxxxxxxxxxxxxx |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Why do we drive on a parkway and park on
http://nadav.harel.org.il |a driveway?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author