Description

KB37200 [juniper.net] demonstrated how to split a tmux window into multiple panes and use each pane to log in to a new Contrail node. When you are working in one of the panes, sometimes your command may give a lengthy and wide output. However, a small pane can make it really hard to read the output.

To ease reading in such cases, two solutions are demonstrated in this article:

  • How to toggle a pane size in tmux

  • How to scroll in the pane buffer

See tmux wiki for further details:  https://github.com/tmux/tmux/wiki

Solution

For example, when you are working in the top-left pane and you input the openstack server list command, the output looks like the following:

    | aba2b81e-da76-41bf-91c7-68df46346522 | vm-pings-ne│  Usage of /:   10.7% of 109.88GB   Users logged in:
    t-cirros-3  | ACTIVE | -          | Running     | pi│ 0
    ngs-net2=2.2.2.8                                  | │  Memory usage: 69%                 IP address for eth0:
    | a96a8597-34c8-4919-a5d0-c645be178398 | vm-pings-ne│ 10.85.188.5
    t-firefly-1 | ACTIVE | -          | Running     | pi│  Swap usage:   0%                  IP address for eth1:
    ngs-net2=2.2.2.3; pings-net=1.1.1.5; mgmt=3.3.3.3 | │ 10.169.4.5
    | 6ad30294-a236-4e1a-a411-0bac40aa9105 | vm-pings-ne│
    t-firefly-2 | ACTIVE | -          | Running     | pi│  Graph this data and manage this system at:
    ngs-net2=2.2.2.6; pings-net=1.1.1.7; mgmt=3.3.3.5 | │    https://landscape.canonical.com/
    | 6a64b345-8801-4727-93b4-03661aa9e75d | vm-pings-ne│
    t-ubuntu-1  | ACTIVE | -          | Running     | pi│*** System restart required ***
    ngs-net=1.1.1.4                                   | │Last login: Fri Jun 25 12:07:29 2021 from pings-t490.jnp
    +--------------------------------------+------------│r.net
    ------------+--------+------------+-------------+---│root@controller2:~#
    --------------------------------------------------+ │root@controller2:~#
    root@controller1:~#                                 │root@controller2:~#
    ────────────────────────────────────────────────────┼────────────────────────────────────────────────────────
    prefix v14.15.1 --silent` to unset it.              │ process
    [2021-06-25 15:49:01]user1@pc1                      │  soft                 Soft reset (SIGHUP) the process
    $                                                   │  |                    Pipe through a command
    [2021-06-28 17:17:40]user1@pc1                      │labroot@router1> restart firewall
    $                                                   │Jun 25 20:21:49
    [2021-06-28 17:17:40]user1@pc1                      │Firewall process started, pid 23334
    $ clear                                             │
    [2021-06-28 17:17:42]user1@pc1                      │labroot@router1>

As you can see, output from the top left pane is hard to read due to the limited room in the current pane. The solution is to temporarily toggle the work area of the current pane to full by pressing ctrl-b + z . Now your current pane will use the "full window" and the other panes will all be hidden, and the output may look better:

    root@controller1:~# openstack server list
    +--------------------------------------+------------------------+--------+------------+...
    | ID                                   | Name                   | Status | Task State |...
    +--------------------------------------+------------------------+--------+------------+...
    | 79759bbd-038b-4eb8-8bf9-fcf2cdb9ea21 | vm-pings-net-cirros-1  | ACTIVE | -          |...
    | f5e36e86-c750-4ca4-9074-6aeb70ef9c71 | vm-pings-net-cirros-2  | ACTIVE | -          |...
    | aba2b81e-da76-41bf-91c7-68df46346522 | vm-pings-net-cirros-3  | ACTIVE | -          |...
    | a96a8597-34c8-4919-a5d0-c645be178398 | vm-pings-net-firefly-1 | ACTIVE | -          |...
    | 6ad30294-a236-4e1a-a411-0bac40aa9105 | vm-pings-net-firefly-2 | ACTIVE | -          |...
    | 6a64b345-8801-4727-93b4-03661aa9e75d | vm-pings-net-ubuntu-1  | ACTIVE | -          |...
    +--------------------------------------+------------------------+--------+------------+...

To go back to the four-pane layout, you need to press the same keys again.

The problem with this solution, however, is that even if you have a "full window" pane, it may not hold the complete output. When the output goes beyond the current screen length, you can only see the bottom portion of it. In this case, you will need to know how to "scroll" up and down in the tmux pane buffer, and tmux's solution is what is called "copy mode," which you can enter by pressing " ctrl-b + [ ".

After executing the above command, you can use the Down/Up/PageDown/PageUp keys to scroll up and down in the current pane buffer and see any part of the historical command output. After you are done, pressing Enter will exit the "copy mode".