Skip to main content

Second terminal without history [Resolved]

I dont know if it possible but i would like use a second term (like terminator) and not use the current $HISTFILE. An amnesic term.


Asked March 20, 2017
Posted Under: Unix Linux
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 with set -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 with unset HISTFILE. If you disable the history file, you still have access to run-time history while the shell is running. You can also set HISTFILESIZE to control the amount of commands saved in the file.

  • Prevent saving certain commands in the history by using HISTCONTROL and/or HISTIGNORE. Setting HISTCONTROL to ignorespace 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 only ls or ls, 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 
if [ -f ~/.bashrc ] ; then
    .  ~/.bashrc
# disable history completely
# disable the history file
# 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.

Answered March 20, 2017

In order not to record the history, you can type unset HISTFILE in the current session (for bash)

Answered March 20, 2017
Your Answer