Zsh Mailing List Archive
Messages sorted by:
Re: Append cancelled commands to history
- X-seq: zsh-users 14223
- From: "Nadav Har'El" <nyh@xxxxxxxxxxxxxxxxxxx>
- To: Vadim Zeitlin <vz-zsh@xxxxxxxxxxxx>
- Subject: Re: Append cancelled commands to history
- Date: Mon, 6 Jul 2009 18:53:37 +0300
- Cc: zsh-users@xxxxxxxxxx
- Hebrew-date: 15 Tammuz 5769
- In-reply-to: <20090706154309.GA15663@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <c16a574a0809181450t61a5b5ddq2e80797fde37636e@xxxxxxxxxxxxxx> <20080919162045.GA22435@xxxxxxxxxxxx> <20090706151644.6BF508027106@xxxxxxxxxxxxxxxxxx> <20090706154309.GA15663@xxxxxxxxxxxxxxxxxxxxxxxxxx>
On Mon, Jul 06, 2009, Nadav Har'El wrote about "Re: Append cancelled commands to history":
> > zle && print -s -- $BUFFER
> I wonder, isn't "-r" also wise to add, otherwise if you have escape sequences
> like "\n", "\c", etc., in your command line, they will be modified by the
> print command?
I added another trick: It annoyed me that if I go back in history and change
my mind, pressing interrupt now will save the whatever command I moved back
to again in the front of the history. I wanted the interrupt key to only save
a new command.
So I added a check for this, using the HISTNO and HISTCMD variables we have
access to: If those are equal, we're editing a new command, but if they're
not, we're on an old command from the history:
# When a line is killed, put it in the history anyway in case we want to
# return to it
# Store the current buffer in the history.
[[ $HISTNO -eq $HISTCMD ]] && # only if we're not back in the history
print -s -r -- $BUFFER
# Return the default exit code so zsh aborts the current command.
Nadav Har'El | Monday, Jul 6 2009, 15 Tammuz 5769
Phone +972-523-790466, ICQ 13349191 |Ways to Relieve Stress #10: Make up a
http://nadav.harel.org.il |language and ask people for directions.
Messages sorted by: