'How to scroll in nested tmux?

Sometimes, I have to use nested tmux session (tmux in tmux). Scrolling by copy-mode does not work in inner tmux session, so it makes me very inconvenient in inner session.

I heard there is meta-key to send tmux command to inner session. Any effective key bind to scroll in inner session?



Solution 1:[1]

tmux copy-mode will do it. Running the command will change to copy-mode in the inner session, and you can scroll as usual.

Another option is using bind and send-prefix, to bind some key to the send-prefix action, which sends the prefix to a nested session. In my case, it is:

set -g prefix C-a
bind a send-prefix

The default prefix is C-b, in that case it may be more reasonable to use b.

With that, you just Control+A (Or B or whatever) and then release Control and hit the same key again (A in my case, B seems better for people using the default C-b prefix, IMHO). That sends the prefix to the inner session. And now whatever you press will trigger a command in the inner session. i.e.: [Control+A] then [%] splits the window vertically for me. That's in the outer session, of course. Then with the send-prefix binding I mentioned, I can do [Control+A] then [A] then [%], and it splits the window in the inner session.

It's pretty nifty, useful for scrolling stuff, searching etc when connected to a server, and once you get used to it it becomes pretty much muscle-memory. Plus you can do [Ctrl+A] then [A] then [D] to detach the inner session, which will either let you exit an ssh connection or end the SSH connection entirely if you have a configuration that automaGically start tmux upon connecting.

And of course, you can bind send-prefix to some other key, possibly with -n so you can have something like [Ctrl+A] as the prefix and something like [Ctrl+S] to send the prefix to an inner session.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fernando Cordeiro