zsh-users
 help / color / mirror / code / Atom feed
* How to (properly) remove the last entry from history with command_not_found_handler
@ 2014-07-20  9:04 Jochen Keil
  2014-07-20 17:45 ` Peter Stephenson
  2014-07-20 18:13 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Jochen Keil @ 2014-07-20  9:04 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-21 17:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-20  9:04 How to (properly) remove the last entry from history with command_not_found_handler Jochen Keil
2014-07-20 17:45 ` Peter Stephenson
2014-07-20 18:13 ` Bart Schaefer
2014-07-20 20:48   ` Jochen Keil
2014-07-21 17:46     ` ZyX

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).