$ eh () { history -a ; vi ~/.bash_history ; history -r ; }
eh stands for Edit History
.
Frequently, I'll mistype a command, and then step back through my history and correct the command. As a result, both the correct and incorrect commands are in my history file. I wanted a simple way to remove the incorrect command so I don't run it by mistake.
.
When running this function, first the ~/bash_history file is updated, then you edit the file in vi, and then the saved history file is loaded back into memory for current usage.
.
while in vi, remember that `Shift-G` sends you to the bottom of the file, and `dd` removes a line.
.
this command is different than bash built-in `fc` because it does not run the command after editing.
by David Winterbottom (codeinthehole.com)