4

My bash command history stops working after starting a new tmux session. No previous commands when typing up, down, reverse search, no output from running history.

I've confirmed that this happens regardless of the .tmux.conf file being used. The real kicker is that this condition persists beyond tmux ... that is, if I ssh to the server without tmux the bash command history still doesn't work. If I move my .bashrc and .bash_profile files (using the system default) and try again, still no history.

I've verified that all the permissions are correct on the history file, my user is both the owner and the group, and even tried setting perms to 777 just to test. For each test I re-executed bash (ie didn't use a subshell).

For some context, this happened after my all my files were copied over to a new server.

Another clue: In the original shell where I started tmux for the first time, if I exit tmux, the command history still works. It is only new shell sessions that are affected.

Some more info:

CentOS release 6.7 (Final)
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
tmux 1.6 (other server was 1.4)

set | grep HIST and hist
HISTCONTROL=ignoredups
HISTFILE=/home/my_username/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:login_shell:progcomp:promptvars:sourcepath

shopt | grep hist
cmdhist         on
histappend      off
histreedit      off
histverify      off
lithist         off

Any help is appreciated!

3
  • 1
    Do you have the same $BASHOPTS, $SHELLOPTS and $- in the working and non-working shells? Does !! work? Do other interactive shell features (e.g. completion) work? Commented Mar 30, 2016 at 20:56
  • @Gilles yes I verified they are the same. $- outputs himBH. !!, !$, etc do not work, (eg -bash: !!: event not found). but $? and $-, etc work. Commented Mar 30, 2016 at 21:36
  • I think this is just the way bash works. Each history is session specific, as I understand this. If you are inclined, you could try zsh which has specific capabilities of sharing history between sessions. Commented Jan 7, 2023 at 12:57

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.