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

Re: how to clean a history entry?

(Back from holiday, too.)

Toshiro wrote:
> I have one problem though, I didn't find the way to remove a specific entry 
> from the history ( in bash I can easily do this with the command 'history -d 
> <item_nr>').
> Anybody know how to do this?

Hmm, I don't think this is too easy.

If you know in advance that you don't want to save an entry, you can set
the option histignorespace and enter a space before the command.  (Note
that it won't disappear until you enter a new command; the immediately
preceeding command is always still available with this option.)

Otherwise, you can save the history (fc -A to append to what's there, fc
-W to overwrite), delete the line from the history file, and read it
with fc -R.  That can probably be turned into a function.  It's a bit

Might not be difficult to add as a feature, since internally history is
held as a linked list.  I can certainly see the use in it when you're
reexecuting chunks of the history.

Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk

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