I would like to configure GNU screen such that it stores the command histories of all the different windows in different files.
I know by default GNU screen does not store the command histories (of its different windows) in a file at all (it stores them in memory instead), but it might be possible to tell it to store them in files instead?
The different command history files should have the names <session>.<window>.history
, or similar.
Does anyone have an idea how to do that?
(Just to be clear, I want each GNU screen window to write a different file. I like that each window has a different history, and I typically run different types of commands in the different windows.)
Create a script somewhere that looks like this.
~/bin/myshell
Adjust your .screenrc with a line like this.
You can manually force a write by running the command
history -w
. I don't believe there is any way to have bash automatically commit the history other then at exit. There appears to be an option to do that in zsh though, search for INC_APPEND_HISTORY.If you want a log of what was done per session you could use script for that. If you wanted to use script to create per session+window log under script you might adjust myshell like this.
Shell history and
screen
history are two different things. A shell remembers commands that you type whilescreen
remembers everything: commands that you type and their output (even the prompt).If you want to keep the history from
screen
then you can use its logging feature. At the end of your~/.screenrc
add these commands: