I don't know if it possible, but I would like use a second terminal (like terminator) and not use the current $HISTFILE
. An amnesic terminal.
2 Answers
Depends on the shell. In Bash, you can control the history in a couple of ways:
Disable saving history using
set +o history
and re-enable it withset -o history
(note the inverted plus and minus). With history disabled, commands entered will not be saved in the history log, but previous ones will be available.Set the file used to save the history, by setting
HISTFILE
(HISTFILE=~/somehistoryfile
). You can disable it completely by unsetting the variable withunset HISTFILE
. If you disable the history file, you still have access to run-time history while the shell is running. You can also setHISTFILESIZE
to control the amount of commands saved in the file.Prevent saving certain commands in the history by using
HISTCONTROL
and/orHISTIGNORE
. SettingHISTCONTROL
toignorespace
will tell the shell to not save command lines starting with a space.HISTIGNORE
can contain patterns of commands not to save in the history. e.g.HISTIGNORE='ls:ls *'
would prevent saving lines that contain onlyls
orls
, a space and anything after that.
For an "amnesiac" shell, you would need to apply one of those settings either manually when opening the shell, or set them in some shell startup script.
One option would be to create, say ~/.bashrc.nohist
with:
# include the standard startup files as --rcfile will override them
if [ -f /etc/bash.bashrc ] ; then
. /etc/bash.bashrc
fi
if [ -f ~/.bashrc ] ; then
. ~/.bashrc
fi
# disable history completely
HISTSIZE=0
# disable the history file
unset HISTFILE
# we could even set a reminder in the prompt
PS1="[nohist] $PS1"
and then arrange the shell to be started with bash --rcfile ~/.bashrc.nohist
. Adjust the script to taste.
In order not to record the history, you can type unset HISTFILE
in the current session (for bash)