Skip to content

Question/Request: Is it possible to remove an item from the history? #1778

Open
@DJackman123

Description

@DJackman123

The [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory method makes it really easy to add a command to the history. Is there a corresponding method to remove a command from the history?

I would like to write a function to bind to a key that would recall the last command from the history so I can correct it. Sort of like an UndoLastCommand function. I would use this after entering a command with a misspelling or other syntax problem. Such a command has no useful purpose in the history (I would never want to execute it again).

Hopefully this description makes sense. Is such a thing possible today? Or would this require some coding within the PSReadLine module before I could write a PowerShell script to do this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions