how can I grab a window from totally different tmux session and attach it as a horizontal/vertical split to current window?
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 (
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 (
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...