Short of doing this, is it possible to move a running command in a pane to another tmux session?
Yes it's pretty easy, use the
move-pane tmux command. For more info run
man tmux | less -I '+/mOVE-pane'
The tricky part is just knowing how tmux references sessions, windows and panes in the commands to manipulate panes etc.
Move into the pane you want to move to the other session
Get the name of the target session by running
On my system that produces:
(0) + 0: 8 windows (attached) (1) + 1: 1 windows ^ | This is the session name. It could be different on your system and it could be a word (not just a number).
Step 3 - run command
<prefix>:move-pane -t <session_name>:<window number> ^^^^^^^^^^^^^^ the name from above goes in here
So on my system I moved into the pane with the running process, ran
<prefix>:move-pane -t 1:1
and the pane with the process in it moved to window one on the session
It gets inserted as a split, so usually you would want to run window on the other session as a throwaway window.
Note: it seems that the target window does need to exist, else the
move-pane command will issue an error.
For more background on the format for specifying sessions, windows and panes within a tmux command, see the section
I can't comment, so I will place it here: for tmux 2.1-3build1~precise the command should be:
<prefix>:move-pane -t session_name:window_number
-- you need a "
-t" before session name (not necessarily a number), and the window with a given number must exist.
P.S. If you type only a
window_number like so:
<prefix>:move-pane -t session_name:,
then your pane will be moved into current window of destination session (and this window will be split).
P.P.S. If you just want to move your window (and not just your pane), then there a good answer on how to Move window between tmux clients:
<prefix>:move-window [-d] [-s src-window] [-t dst-window]
dst-window have the form