55

I am running 12.04 server and when I type history in bash I see most of the commands I have entered into bash but I don't see the commands I have entered when in a tmux session.

How do I see the history of the commands I have run inside a tmux session on Ubuntu 12.04 server after I have ended the session?

2 Answers2

48

You have to preserve bash history in multiple bash shells. To do this, be sure that you have the following lines in your ~/.bashrc file:

# avoid duplicates..
export HISTCONTROL=ignoredups:erasedups

# append history entries..
shopt -s histappend

# After each command, save and reload history
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

Source: https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows

Radu Rădeanu
  • 174,089
  • 51
  • 332
  • 407
0

To enable bash history in tmux, run bash on tmux startup. To do this, put this line into your .tmux.conf file:

set-option -g default-command bash
4dc0
  • 101
  • 2