Execute a terminal command without saving it to .bash_history on OS X?

Solution 1:

Add the following line to ~/.bashrc

export HISTCONTROL=ignorespace

Then source ~/.bashrc to refresh the settings

This should enable that feature in bash. If it doesn't work, you might have to add it to ~/.bash_profile instead of ~/.bashrc since OS X loads them a bit differently than linux I think.

Solution 2:

If you're not concerned about keeping the session active, this may work:

kill -9 $$

It will kill the current session instead of logging-out, which [theoretically] means your history will not be saved.