Tmux – Moving Pane to Window

tmux

How do I move an existing pane into another window in tmux when I have multiple windows, and vice versa?

I'm coming from screen, where I can switch to the pane and then switch windows until I get to the one I want; tmux does not seem to allow this.

Best Answer

The command to do this is join-pane in tmux 1.4.

join-pane [-dhv] [-l size | -p percentage] [-s src-pane] [-t dst-pane]  
    (alias: joinp)
    Like split-window, but instead of splitting dst-pane and creating
    a new pane, split it and move src-pane into the space.  This can
    be used to reverse break-pane.

To simplify this, I have these binds in my .tmux.conf for that:

# pane movement
bind-key j command-prompt -p "join pane from:"  "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:"  "join-pane -t '%%'"

The first grabs the pane from the target window and joins it to the current, the second does the reverse.

You can then reload your tmux session by running the following from within the session:

$ tmux source-file ~/.tmux.conf
Related Question