I am running a tmux session with 40 windows. I need to create an overview window listing the last line of each screen and updating each listing as the output of the respective window.
1 Answer
The idea is to enumerate all the windows, or rather all the panes, since a window can have several of them. Then capture the output of each pane and display the last line of captured text. Put this into a script:
tmux list-windows -F '#I' |
while read w; do tmux list-panes -F '#P' -t $w |
while read p; do echo -n "${w}.${p}" ; tmux capture-pane -p -t "${w}.${p}" |
tail -n 1
done
done
Suppose you put this code in /some/file
After that, being in your 40 window tmux session, you create your new monitoring window, and run
watch -n 1 'bash /some/file'
in there. The echo -n "${w}.${p}" ; part will prepend the lines with the window and pane index, I found it's rather useful to have an idea of the output origin. You may not want it.
-
This works! thanks! However, the colors and indentation of the original output are lost. Any thoughts on that?Corstiaan– Corstiaan2017-10-23 20:34:59 +00:00Commented Oct 23, 2017 at 20:34
-
Not really. Though you can preserve any escape sequences with -e option of capture-pane command you still will need to have somtehting to handle them correctly. tail cannot that but I think that may give you the direction.Tagwint– Tagwint2017-10-23 20:55:02 +00:00Commented Oct 23, 2017 at 20:55