My current screen
session has 12 open windows on it. It's been running for weeks... I know I executed an ImageMagick convert
command in one of these 12 screen windows sometime last week... is there any way I can easily search through the Bash history of all 12 instances, without closing them or running history | grep convert
in all 12 screens?
tcsh allows you to share history between sessions through use of the periodic alias.
In your .cshrc (or .tcshrc) file:
set tperiod = 60 #(or any other number. Time in minutes between refreshing)
alias periodic 'history -S; echo "Syncing history"'
This will automatically execute the history command every 60 minutes. This will save history to a common history file in your home directory. To update the history more often, either lower the tperiod number, or simply execute the "periodic" command to manually refresh
Sounds difficult. Here are a couple of methods that may work for you.
If you have process accounting tools installed (on Linux, look for a package called acct
) and the permission to use them, you can find out when and possibly on what terminal you ran convert
If this is unavailable or unconclusive, you can execute a history
command in each instance of bash to look for convert
commands. This will find commands that were in the history file when bash started as well.
for w in $(seq 0 11); do
screen -p $w -X stuff \
'history | sed 's/^.*convert/'$w'&/" >>/tmp/convert.history
$(seq 0 11)
iterates over the numbers of your screen windows. Make sure to skip windows that are not currently running bash but some other process that would interpret input differently.screen -p $w stuff …
sends the following string as input to the specified window. You need the newline at the end of the string.The file /tmp/convert.history
will contain a list of lines like3 convert foo.jpg
, if you ranconvert foo.jpg
in window 3.