Can I see what's going on in a tmux session without attaching to it?

I think capture-pane might suit your needs:

tmux capture-pane -pt "$target-pane"

(see “target-pane” in the man page for the ways to specify a pane)

By default, that command will dump the current contents of the specified pane. You can specify a range of lines by using the -S and -E options (start and end line numbers): the first line is 0, and negative numbers refer to lines from the pane’s “scroll back” history. So adding -S -10 gets you the most recent ten lines of history plus the current contents of the pane.

tmux capture-pane -pt "$target-pane" -S -10

The -p option was added in 1.8. If you are running an earlier version then you can do this instead:

tmux capture-pane -t "$target_pane" \; save-buffer - \; delete-buffer

But mind those semicolons if you are issuing this command via ssh since the remote shell will add an additional level of shell interpretation (the semicolons need to be passed as arguments to the final tmux command, they must not be interpreted by either the local or the remote shell).

Tags:

Tmux