Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

how can I grab a window from totally different tmux session and attach it as a horizontal/vertical split to current window?

share|improve this question
add comment

2 Answers

up vote 28 down vote accepted

Sounds like you're looking for join-pane. Technically for the second part of your question you want to join a pane to the current window, not the full window from the other session since that could include multiple panes.

Here's an example. Let's say you're in session 0, window 4 and in session 2 that you want window 3's pane 1. In the tmux prompt (ctrl+b : by default)

join-pane -s 2:3.1

This will move pane 1 from window 3, session 2 (-s is the source window and takes the format session:window.pane) to your current session (session 0).

Below are the full docs for join-pane, which you can get from the tmux man page. The most confusing part for me reading the docs was figuring out the format that was expected for src-pane specifying session, window and pane numbers (session:window.pane per the example above). You can also name your sessions and windows and use those names instead of the index numbers.

 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.
share|improve this answer
2  
Can I copy a pane instead of moving it? –  pielgrzym Apr 27 '11 at 16:57
    
@pielgrzym I'd love to know the answer to that too. Please post it here if you find it. –  Richard Bronosky Feb 1 '12 at 16:29
add comment

If you are trying to join panes from within the same session, you will instinctively want to omit the "session:" from the command. This will fail. It seems that the -s and -t switches to join-pane accept the argument in the form of [session]:window[.pane] instead of [session:]window[.pane]

That is to say, the session is optional and the : is mandatory. This is goofy. It would be the equivelent of browsers requiring http://google.com:/ as the shortcut version of http://google.com:80/ and giving an error to http://google.com/ o_O

Since ctrl-b ! breaks the current pane into a separate window (which is the opposite of what we want to do), and ctrl-b @ (which is right beside !) is unbound by default (meaning you are not overwriting anything) I suggest creating this shortcut...

bind-key @ command-prompt -p "create pane from:"  "join-pane -s ':%%'"
share|improve this answer
    
Nice binding there . –  Nishant Jul 2 at 19:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.