title: Can you prevent a command from going into the bash shell command history?
body: <p>Is there a way to prevent a command from being added to the bash shell's command history?</p>
  
  <p>I would like to be able to prevent certain "dangerous" commands from being added to the history, such as "<code>rm -rf ~/some/dir</code>", so that it is not accessible to me by pressing the up-arrow to reach previous commands.  In this way, it would not be possible to accidentally repeat one of these commands.</p>
  
  <p>The reason I ask is that I use the up arrow a lot to access previous commands in the shell history, and have often caught myself about to hit enter on what I <strong>thought</strong> was the correct command, only to realise that I was about to do something stupid/annoying/dangerous.  I don't like the idea of <code>rm</code>s etc floating around in my shell history, waiting for me to step on them!</p>
  
  <p>(Note: I am aware that one can set up patterns in HISTIGNORE, but what would be nice is something one can apply on a per-command basis, which would become good a habit.  Unless there is a clever way to achieve this using HISTIGNORE that I have missed?)</p>