sessionwindowtmux

How can I move a window to another session in tmux?


In tmux, how can I move a window from a session to another session?

ex. move window:4 in session [0] to session [4] .


Solution

  • From my testing on tmux 2.6, you'll need two things for the command to move an entire window over:

    From this point, you can just change to the session you want to move the window into, <tmux-escape>: into a command prompt, and type a command of this form:

    move-window -s $session_name[:$window_index]
    

    ...where, as noted before, the $window_index is optional (as indicated by the square brackets, which aren't actually part of the syntax ). To use some concrete examples:

    # Moves from currently-focused window from session named `$session_name`
    move-window -s $session_name 
    
    # Moves from window with index `$window_index` from 
    # session named `$session_name` into the current session
    move-window -s $session_name:$window_index
    

    Et voilĂ ! Your window got moved. :)