Description

Using Tmux in RHOST13 based contrail setup is convenient and productive in terms of smoothing the operation and troubleshooting workflow. KB37199 [juniper.net] through KB37205 [juniper.net] explains the most common usage cases. However, problems may occur when a user already uses Tmux in their local laptop.

In this scenario, starting a remote Tmux session from within the local Tmux session leads to a "nested Tmux" usage. For ease of description, we will call the local Tmux (launched from local PC) "outer tmux", and the remote Tmux (launched from the server via SSH) "inner" Tmux.

Symptoms

With nested Tmux, one issue is the confliction of the Tmux "prefix key". By default, "ctrl-b" is used by Tmux as the "prefix key". A "prefix key" is a key intercepted by Tmux as a signal that any of the following characters you type are commands sent to, and executed by Tmux only.  The application running inside of Tmux will not receive them. With nested Tmux, however, there is
a problem. Since the "outer" Tmux will intercept "ctrl-b", which is the default Tmux "prefix key", the "inner" Tmux will never receive it.

Solution

A recommended workaround is to configure the outerTmux, so that when pressing a different key, such as ctrl-a , it triggers a new ctrl-b keypress event, which is then sent to whatever is running inside of it; the inner Tmux. 

Instructions with the Tmux command to make this happen:

  1. Press ctrl-b to alert the outer Tmux session that a Tmux command will be entered:

    ctrl-b
  2. Press semicolon to enter Tmux command mode:

    :

    The Tmux CLI tells the outer Tmux that whenever a ctrl-a is received, send the prefix key to the apps running inside of it. By default, the Tmux prefix key is ctrl-b , so a ctrl-b will be sent to the inner Tmux bind-key -n C-a send-prefix.

  3. Press enter
After that:
  • When pressing ctrl-b: , the Tmux command will be accepted by outer Tmux
  • When pressing ctrl-a: , Tmux command will be accepted by inner Tmux