0
votes

I am running a lot of tmux session like

Each tmux session is started as:

today=`date +%Y-%m-%d-%H_%M_%S_%N`
tmux new-session -d -s "$today" zsh /home/path/to/script.sh "with_params"

If i want to only view the list of tmux sessions. I can do by

 tmux ls | awk '{print $1}';

Now what i want is to monitor their output using the while loop to show the session name and the recent output:

while true;
do;
        echo "##########################################"  
       ??? For list of tmux session; do
        sleep 1;
        ??? session name
        ??? recent last 5 lines of output
        done
        echo "##########################################"
done;

??? : What commands should i use

1

1 Answers

1
votes

You can use capture-pane to show the last five lines of output:

tmux capture-pane -p -S- -E-|sed '/^$/d'|tail -5

Add -t to specify the pane you want to see - if you just give a session it will use the active pane in the current window.

Add -e if you want colour sequences included.