Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


So ./bash_history simply seems to be empty.

Where is the history for each bash within screen stored?

share|improve this question
up vote 1 down vote accepted

History is only flushed to file when the shell exits.

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

share|improve this answer

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"
share|improve this answer

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .