0

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.

2

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 Oct 23 '17 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 Oct 23 '17 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.