Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Append cancelled commands to history



On Mar 26, 11:23pm, Nadav Har'El wrote:
}
} What I still find a bit odd is the fact that this behavior (of saving
} the partially entered command in a special place outside the history)
} is only applied to whole lines of multiline commands, and not to
} interrupted single line commands

Once again, it depends on whether you interrupt an instance of the line
editor.  Every time you hit "enter", you've completed one instance of
the line editor and started a new one.  You're not interrupting a
syntactic construct, you're interrupting an editor instance.

If you were to write the entire multi-line construct in a single editor
instance, by using ESC-Enter to input literal newlines without starting
a new PS2 prompt, then the interrupt would discard the entire multi-
line command just as it discards a single-line command.

} 2. Why is that special (out of history) memory location for one last
}    command is needed, or even desired.

It's derived from the way that history references work in csh.  Even
if you set HISTSIZE=0 so that no history is ever saved, references to
the immediately preceding command with the "!!" syntax are required
to work.  Hence that preceding command is always kept around, and
there's no good reason not to allow you to scroll back to it with the
line editor.

As I mentioned before, it's also related to the options that allow you
to automatically exclude things from the history file (especially the
HIST_NO_STORE and HIST_IGNORE_SPACE options).  The most frequent
reason to want to retrieve a line from the history is because you
made a typo.  If you make a typo on a line you otherwise intend to
exclude from the history, wouldn't you find it annoying to have to
re-type the whole line?



Messages sorted by: Reverse Date, Date, Thread, Author