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
- X-seq: zsh-users 18969
- From: Jochen Keil <jrk@xxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: How to (properly) remove the last entry from history with command_not_found_handler
- Date: Sun, 20 Jul 2014 11:04:12 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sternenrei.ch; s=default; t=1405847052; bh=BUxutHcaaASDxZI90y7Rojq0qkMyv6rRGVNFEI7IK5I=; h=Date:From:To:Subject:From; b=fvywMNI5nBlymq39uMTmWztA0TPxV88Y2uqWPPj0krpf2yQhJme2MKm+sviwqHWC6 mOQXubioP5w2chOoNZcjqW/K6t8wbWAk7yb7BMTFb3LfaPEVS89K8zGAXp4dCMi56j fm7lvnUNX3mVdND89yPDz2A+4iUJ6L5i6dBoMvIc=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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