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

Re: history editing

On Fri, 16 Nov 2001, Danek Duvall wrote:
> My normal course is to delete the last few lines of the history.  And
> while they disappear from the end of the history, they reappear at the
> beginning.  Re-running the function -- where those lines don't appear in
> the editor at all -- makes them disappear entirely.

This seems like the proper thing for your cited function to do.  I'm
assuming you have SAVEHIST and HISTSIZE set to the same value, right?
To see how this works, assume that this value is 100.  You edit the file
down to 97 lines by removing the last 3 lines and then load the history
file.  This pushes the 97 lines onto the history, and the first 3 still
remain up at the top.  If you repeat the sequence, they get pushed off
into oblivion by the re-reading of the same 97 lines.

So, there's nothing wrong with how your function works that I can see.
You could change it to discard the old history if you wanted to, though:

edh() {
    local histfile histsize


    fc -AI $histfile
    vi + $histfile
    fc -R $histfile


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