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

How to (properly) remove the last entry from history with command_not_found_handler



Dear list,

I'm trying to remove the last entry from my $HISTFILE when the command
was not found. My current attempt involves the
command_not_found_handler() hook:

function command_not_found_handler()
{
    sed -i '$d' $HISTFILE
    return 127
}

However, I'm not sure if it's ok to manipulate the history file directly
with sed, or if I'm risking corruption.

Thank you very much and best wishes,

  Jochen



-- 
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

- William Blake, Auguries of Innocence

Attachment: signature.asc
Description: OpenPGP digital signature



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