See more: http://www.ruanyifeng.com/blog/2019/10/tmux.html https://thevaluable.dev/tmux-config-mouseless/

Concepts

tmux allows you to have multiple panes (the equivalent of windows in Vim) and windows (the equivalent of tabs). To access tmux functionality, you first need to hit a prefix key, followed by a command. The default prefix key is Ctrl + b.
image.png

Configuration

Configuration file

  • /etc/tmux.conf: system-wide configuration
  • ~/.tmux.conf: user configuration

    Prefix key

    ```bash

    ~/.tmux.conf

Use Ctrl-\ as a prefix.

unbind-key C-b set -g prefix ‘C-\’ bind-key ‘C-\’ send-prefix

  1. <a name="lgzOl"></a>
  2. ### Spit screen vertically and horizontally
  3. ```bash
  4. # ~/.tmux.conf
  5. # Use - to create vertical splits.
  6. bind - split-window -v
  7. unbind '%'
  8. # Use | to create horizontal splits.
  9. bind | split-window -h
  10. unbind '"'

Navigate between panes

  1. # ~/.tmux.conf
  2. bind h select-pane -L
  3. bind j select-pane -D
  4. bind k select-pane -U
  5. bind l select-pane -R

Enable mouse

  1. # ~/.tmux.conf
  2. set -g mouse on

Restart tmux (or execute Ctrl + b followed by :source-file ~/.tmux.conf) to apply the configuration.

Start & Exit

  1. $ tmux
  1. $ exit

Resize Panes

See more: https://linuxhint.com/adjust-tmux-pane-size

Attach, Dettach, List sessions

List

  1. $ tmux list-sessions
  2. 0: 1 windows (created Sun Jan 30 19:38:38 2022) (attached)

Dettach

CTRL+b+d

Attach

  1. $ tmux attach[-session] -t 0