tmux 嵌套 tmux
by Alexey Samoshkin
通过阿列克谢·萨莫什金(Alexey Samoshkin)
Tmux实践:本地和嵌套远程tmux会话 (Tmux in practice: local and nested remote tmux sessions)
我们讨论了tmux功能,它们与本地和远程方案的相关性以及如何设置和配置tmux以支持嵌套会话 (We discuss tmux features, their relevance for local and remote scenarios, and how to setup and configure tmux to support nested sessions)
This is the first part of my tmux in practice article series. It is about using and configuring tmux v2, local and remote tmux sessions usage, and how to support a scenario when a remote tmux session is going to be nested inside a local tmux session.
这是我的tmux实践文章系列的第一部分。 它是关于使用和配置tmux v2,本地和远程tmux会话的用法,以及如何支持将远程tmux会话嵌套在本地tmux会话中的情况。
Before you start reading, here is a working example from my machine. We have a local tmux session on OSX inside iTerm2 (run in full screen mode). The local session has 2 windows: “zsh” and “node”.
在开始阅读之前,这是我机器上的一个有效示例 。 我们在iTerm2中的OSX上有一个本地tmux会话(以全屏模式运行)。 本地会话有2个窗口:“ zsh”和“ node”。
The “zsh” window is split into 2 panes: in both panes we SSH’ed to the remote hosts (CentOS7 and Ubuntu14) and jump into remote tmux sessions there.
“ zsh”窗口分为两个窗格:在两个窗格中,我们都通过SSH方式连接到远程主机(CentOS7和Ubuntu14),然后跳到那里的远程tmux会话。
The bottom pane with the Ubuntu14 remote session is further split into 2 panes, and we have 3 windows: shell, mon, and logs.
带有Ubuntu14远程会话的底部窗格进一步分为2个窗格,我们有3个窗口:shell,mon和log。
If you’re curious how it all works together, continue reading.
如果您好奇如何将它们一起使用,请继续阅读。
特征 (Features)
First let’s quickly go through tmux features and advantages, to understand their relevance to local or remote scenarios. We should clarify to ourselves why we need this “nested tmux in tmux” thing, because at first glance it looks pretty crazy.
首先,让我们快速浏览tmux的功能和优点,以了解它们与本地或远程方案的相关性。 我们应该向自己说明为什么我们需要这种“嵌套的tmux in tmux”,因为乍一看它看起来非常疯狂。
Terminal multiplexing, named windows, split window into several panes. This makes more sense for the local environment, when you decide to supercharge your terminal emulator, which otherwise does not support aforementioned features. For example, iTerm or Terminator are already capable of multiplexing a terminal.
终端多路复用(称为窗口)将窗口分为几个窗格。 当您决定为终端仿真器增压时,这对于本地环境更有意义,否则它将不支持上述功能。 例如,iTerm或Terminator已经能够复用终端。
Setup and kick off tmux session with a pre-configured set of windows and panes, their arrangement, and commands run inside to avoid hassle of repeatedly setting up them again and again from scratch. For example:
使用一组预先配置的窗口和窗格,它们的排列和命令来设置和启动tmux会话,以