How to run nested tmux session

tmux is a program that provides convenient way for getting multiple terminal sessions into one window. If you are using it a lot, quickly you can find yourself asking for more – multilevel tmux. Example of nested tmux session:

There are 2 sett…

tmux is a program that provides convenient way for getting multiple terminal sessions into one window. If you are using it a lot, quickly you can find yourself asking for more – multilevel tmux. Example of nested tmux session:

There are 2 settings necessary for this set up to work as expected. Inside ~/.tmux.conf you need:

bind-key -n c-g send-prefix
bind-key -n c-t send-keys c-g

for prefix key access to nested windows. The default prefix is ctrl+b, so here I’m setting ctrl+g to work as prefix on the second level of tmux, and ctrl+t to work on the third level.

Thanks to configuration like this, if you use ctrl+b & c to create a new window on the first level of tmux, you will use:

  • ctrl+g & c – to create window on the second level
  • ctrl+g & c – to create window on the first

The other setting is inside your .zshrc or .profile:

unset TMUX

If we skip this, we will end up seeing:

$ tmux new -s test
sessions should be nested with care, unset $TMUX to force



Summary

In this short guide we have seen how to set up our tmux to support nesting with minimal configuration & nice mapping for prefix key. Let me know in the comments if you are interested in more tmux or command line tips.


Print Share Comment Cite Upload Translate
APA
Marcin Wosinek | Sciencx (2024-03-29T13:41:43+00:00) » How to run nested tmux session. Retrieved from https://www.scien.cx/2021/07/10/how-to-run-nested-tmux-session/.
MLA
" » How to run nested tmux session." Marcin Wosinek | Sciencx - Saturday July 10, 2021, https://www.scien.cx/2021/07/10/how-to-run-nested-tmux-session/
HARVARD
Marcin Wosinek | Sciencx Saturday July 10, 2021 » How to run nested tmux session., viewed 2024-03-29T13:41:43+00:00,<https://www.scien.cx/2021/07/10/how-to-run-nested-tmux-session/>
VANCOUVER
Marcin Wosinek | Sciencx - » How to run nested tmux session. [Internet]. [Accessed 2024-03-29T13:41:43+00:00]. Available from: https://www.scien.cx/2021/07/10/how-to-run-nested-tmux-session/
CHICAGO
" » How to run nested tmux session." Marcin Wosinek | Sciencx - Accessed 2024-03-29T13:41:43+00:00. https://www.scien.cx/2021/07/10/how-to-run-nested-tmux-session/
IEEE
" » How to run nested tmux session." Marcin Wosinek | Sciencx [Online]. Available: https://www.scien.cx/2021/07/10/how-to-run-nested-tmux-session/. [Accessed: 2024-03-29T13:41:43+00:00]
rf:citation
» How to run nested tmux session | Marcin Wosinek | Sciencx | https://www.scien.cx/2021/07/10/how-to-run-nested-tmux-session/ | 2024-03-29T13:41:43+00:00
https://github.com/addpipe/simple-recorderjs-demo