3

I am using the linux-utility 'screen' (I mean the terminal multiplexer).

In each "window" of screen, I am running bash.

But these bashes do not seem to have any command history.

For example, if I type this in of the bashes within screen:

[gojira@cray]$ date

Mon Jun  6 17:50:51 JST 2011

[gojira@cray]$ grep date ~/.bash_history

[gojira@cray]$

So ./bash_history simply seems to be empty.

Where is the history for each bash within screen stored?

3 Answers 3

1

History is only flushed to file when the shell exits.

Try the history bash built-in for access to more recent command history.

3

The history is saved to $HISTFILE (default ~/.bash_history). If this variable is empty, no history file will be created. The history is saved when the shell is exited, not before.

To test whether your history has been enabled or not, run:

echo "$HISTFILE"
0

You might want to add shopt -s histappend to your .bashrc.

This will append the content of your terminal history to your .bash_history on exit. Otherwise .bash_history will be overwritten on exit. This means that you may loose some of your command history if you're using multiple bash shells at once and close them.

You must log in to answer this question.