Is there a way to prevent adding a command to the bash shell command history?
I would like to be able to prevent some โdangerousโ commands from adding to the history, for example, โ rm -rf ~/some/dir โ so that it is not accessible to me by pressing the up arrow to reach the previous commands. Thus, it would be impossible to accidentally repeat one of these commands.
The reason I ask is because I repeatedly use the up arrow to access previous commands in shell history and often find myself getting into what I thought was the right team, only to understand that I was going to do something stupid / annoying / dangerous. I don't like the idea of rm , etc., floating in my shell story, waiting for me to step on them!
(Note: I know that you can customize templates in HISTIGNORE, but what would be nice is that you can apply based on each command, which will be a good habit. If there is no smart way to achieve this using HISTIGNORE, which I missed?)
linux unix bash shell
KarstenF Mar 12 '09 at 20:43 2009-03-12 20:43
source share