Moving tmux pane to window

  • 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.

  • jasonwryan

    jasonwryan Correct answer

    9 years ago

    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

    I'm trying this method but when I put your code into my .tmux.conf file and do Ctrl-b, j, nothing seems to happen.

    You need at least 2 windows open, with a couple panes in each: then hit `Prefix+s` and *enter the window name at the prompt* to send the pane to that window...

    I am still not having any luck with this, nothing happens. I get the feeling tmux is not reading the .tmux.conf file because it does not respond at all to Ctrl-b, j or Ctrl-b, s. (these are the only 2 lines in the config file)

    Have you reloaded the .conf file after creating it? Ctrl-b r?

    Yes, I have. it works is I manually enter the commands breakp or joinp, your config just does not seem to have any effect on my system.

    I left the first comment line in it, would that be causing any problems?

    No - comments have no effect. Perhaps edit your question and include more information (version number, distro etc) - that might help diagnose your second issue. Glad you got it working though...

    How do I find my tmux version? -V, -v, --version, etc.. don't seem to work. It's the latest version on Debian 6.

    If the -V switch doesn't work, it is pre-1.4. Build your own current version and you will be good to go...

    Found it, I'm running 1.3-2. Ill try updating.

    @mrlanrat I find that you must prefix the window number with a colon. See my answer below.

    Note that this process: join pane, break pane, will remove any window-renames you've done. Any way around that?

    Great. Since i'm using `h j k l` to move "vi style" between panes, i used `>` and `<` to "send pane" and "bring pane" from windows.

    What does the '%%' refer to?

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM