[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature: Easily remove current command from history

From: Dennis Williamson
Subject: Re: Feature: Easily remove current command from history
Date: Mon, 4 Jan 2016 16:05:24 -0600

On Mon, Jan 4, 2016 at 3:07 PM, Eduardo A. Bustamante López <address@hidden> wrote:
Take into account that many options have been provided (history -d, the space
prefix, even editing .bash_history yourself).

But you request a single key stroke to do this... why?

If you enter a password by mistake in your shell, and it gets recorded, then
you go and clean up. It's not hard to do.

But since you request a simple-and-easy way of doing this, it seems like you do
this a lot... which you shouldn't! :-)

Now, it is up to you to convince Chet that it is so important to have a simple
shortcut to do this. IMO, it isn't.

Eduardo Bustamante

Just bind your own keystroke to a function which uses history -d:

histdel() {
    local last_command histline

    last_command=$(history 1)

    histline="${last_command%  *}"

    history -d "$histline"    #  I wish history -d accepted negative offsets

bind -x '"\ez": histdel'

Then Esc-z or Alt-z will delete the most recent history entry. You could choose another keystroke to bind.

Visit serverfault.com to get your system administration questions answered.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]