Temporarily suspend bash_history on a given shell?

This should be what you're looking for:

unset HISTFILE

From man bash

If HISTFILE is unset, or if the history file is unwritable, the history is not saved.

Alternatively, if you want to toggle it off and then back on again, it may be easier to use set:

Turn Off

set +o history

Turn on

set -o history

Using bash, set HISTCONTROL="ignorespace" and precede with space any command you do not wish to be recorded in history. In case you forgot to take any measures, there is also history -d <number> for deleting a specific entry or history -c for clearing the entire command history.


Make sure that HISTCONTROL contains ignorespace. You'll probably want to add HISTCONTROL=ignorespace (or HISTCONTROL=ignoredups:ignorespace or something) to your ~/.bashrc. Then any command line that begins with a space is omitted from the history.

Another possibility is to start a new bash session that doesn't save its history.

$ bash
$ unset HISTFILE
$ sooper-sekret-command
$ exit
$ #back in the parent shell