Terminal multiplexer

From 太極
Jump to navigation Jump to search


Ways to Keep Remote SSH Sessions and Processes Running After Disconnection

5 Ways to Keep Remote SSH Sessions and Processes Running After Disconnection


A tiling terminal emulator for Linux using GTK+ 3

  • https://gnunn1.github.io/tilix-web/ and Ubuntu PPA for the latest version.
  • Zoom in by Ctrl + Shift + Plus sign.
  • Change color them by using 'profile.
  • Tilix: The Almost Perfect Tiling GTK+ 3 Terminal Emulator. You can save and load terminal groups, so you can easily pick up from where you left off, using the exact same terminal layout. My testing is it only saves the layout but not the directories in each pane.
  • Not quite understand the advantage of it compared to terminator


  • 20 Useful Terminal Emulators for Linux
  • https://wiki.archlinux.org/index.php/Terminator (include some keyboard shortcuts)
    • Ctrl + Shift+ O Split terminals horizontally
    • Ctrl + Shift+ E Split terminals vertically
    • mouse can be used to resize split screens and switch to each screen
  • Change the default window size
    • Method 1: it can only change the size. nano ~/.config/terminator/config
    • Method 2: it can change both the size and geometry position. --geometry parameter.
  • Change the font size. I pick 'Ubuntu Mono Regular' 14.
  • Keyboard shortcuts
    • Shift + Ctrl + p/n: switch to the previous/next view
    • Ctrl -: decrease font
    • Shift Ctrl +: increase font
  • You can take a screenshot to record the directories for all split screens.
  • Right click to open the Preferences. We can change the number of scroll back there to infinity.
  • To change the title (From the Terminator man pages),
    • Ctrl+Alt+W Rename window title.
    • Ctrl+Alt+A Rename tab title.
    • Ctrl+Alt+X Rename terminal title.

GNU screen

How to do it...

  • Run screen command first (run sudo apt-get install screen if necessary). You are now inside of a window within screen. This functions just like a normal shell except for a few special characters.
  • Create screen windows: Ctrl + a, then c. To close a screen window: exit. Once you close all screen windows, you shall see a message [screen is terminating] on the terminal.
  • View a list of open windows: Ctrl + a, then ".
  • Switch between windows: Ctrl + a and n for the next window and Ctrl +a and p for the previous window.
  • Attaching to and detaching screens: To detach (save) from the current screen session, Ctrl +a, and d (these keyboard shortcuts won't affect current execution). This will drop you into your shell. This is useful when you need to run a time-consuming job or your connection is dropped. To attach to an existing screen, use:
screen -r -d
  • Split screen:
    • To split the screen horizontally, Ctrl +a and S (capital).
    • To unsplit the screen, Ctrl +a and Q (capital).
    • To switch from one to the other: Ctrl +a and TAB.
    • Note: After splitting, you need to go into the new region and start a new session via Ctrl + a then c before you can use that area.



  • Split screens
  • Don't worry about connection broken (if used remotely) or computer shutdown unexpectedly (it used locally)
  • Remember the session including split screens even computer shutdown for any reason. Useful for running a long job (wget, rsync, et al).

Most important keyboard shortcuts:

Keyboard Action
(ctrl+b), ? Show key binding
(ctrl+b), " split the pane horizontally
(ctrl+b), up/down arrow key move around panes
(ctrl+b), d



quit a session

$ tmux ls list sessions
$ tmux attach -t 0 re-attach session 0
(ctrl+b), :

(ctrl + ⌥ )

resize-pane -U 10

resize-pane -D 10

resize pane

resize the current pane up (works for all four arrows)

increase pane height by 10

decrease pane height by 10

(ctrl+b), [

'q' to quit

scrollback (Enter copy model)
(ctrl+b), [



(ctrl+b), ]

$ tmux save-buffer foo.txt

copy mode in vi style keybindings

Use the arrow key to go to the top first. Select the top of the text

Use the arrow key to go to the bottom. Select the Bottom of the text and copy

Paste (works in tmux window only. To get the tmux buffer in system clipboard, see here)

Save the buffer to a file

My ~/.tmux.conf file

set -g prefix C-a  # change prefix from (C-b) to (C-a)
unbind C-b
bind C-a send-prefix
set -g mouse on                   # use mouse to scroll and switch panes
set-window-option -g mode-keys vi # for copy-paste

Raspberry Pi zero

It seems tmux uses too much resource. The CPU shows 100% usage. After I uninstall tmux, the CPU shows 2-3% usage.


Byobu is a GPLv3 open source text-based window manager and terminal multiplexer. It appeared at Think inside the box.


Most important keyboard shortcuts:

Keyboard Action
Shift + F2 split the pane horizontally
Shift + up/down arrow key move around panes
Shift + Alt + up/down key resize panes
F6 detach


  • Mouse is useless
  • When used with iTerm on Mac, some keys may have a different behaviors.
  • If we want to use the 'byobu' command remotely, we first run a ssh connection to a remote computer. Then we type 'byobu' to start a new session. After some operations, we can type 'exit' to quit the session or use "F6" to detach the session and return to a normal ssh connection.
  • Kill a frozen session by byobu kill-session -t 1 where "1" is the session number obtained by byobu list-session
  • Cf Session (a complete new terminal), Windows (count from 0, see the status bar), Split (also called pane)
  • Some all keyboard shotcuts rely on the Fx keys. It is not easy or may fail to do that on Mac (needs to hold the 'fn' key) keyboard on a ssh connection.
  • F1 to go to help, e.g. key bindings. ESC to go back.
    • Shift-F1 will open a new window (check the status bar for a new number). 'q' to quit the Help Window.
    • Use Alt + Left/Right to move focus among windows
  • F2 - create a new window. F3/F4 (or Alt-Left/Alt-Right) - move to previous/next window
    • Ctrl-Shift-F2 - create a new session (not work on Mac keyboard?)
    • Alt-Up/Down to move between sessions
  • Split screen
    • Horizontal (up and down): Shift + F2.
    • Vertical: Ctrl + F2.
    • Again you cannot use mouse to move the focus:(
    • Shift + Left/Right/Up/Down to move focus among splits
    • 'exit' to close a split
    • Shift-F6 to kill a split
    • Shift + Alt + arrow keys: resize split screen
  • F5 reload profile, refresh status
  • F6 Detach session and then log out (type 'byobu' to connect again). That is, even you closed a byobu window, it is still in the background. We can test it by using 'htop' or 'ping' commands.
    • Type 'ps -ef | grep byobu' in the ssh connection to find out detached byobu sessions
  • F7 Enter scrollback mode
    • Move the cursor to the start of the text you want to copy, hit "Space"
    • Move the cursor to the end of the text you want to copy and hit "Enter"
    • To paste text, open a text editor and hit Alt + Insert or ctrl-a-]. The first time to use ctrl-a, we need to choose either Screen or Emacs mode (I choose Screen). Use byobu-ctrl-a to reconfigure change this selection. See Ubuntu page.
    • Alt-PageUp/PageDown - enter and move through scrollback (fn+Alt+Up/Down on Mac keyboard)
  • F8 Rename the current window
    • Shift-F8 Rename the current session (not work on Mac keyboard)
  • F11
    • Shift-F11 Zoom in/out a split
    • Alt-F11 Break a split to a full window
  • F12
    • Shift-F12 Toggle on/off Byobu's keybindings (say, Byobu's keybindings conflict with some other program)
    • Alt-F12 Toggle on/off Byobu's mouse support (move around splits and resize split size). It becomes more complex when we want to select text.