tmux


tmux ~> Terminal MUltipleXer


architecture


session 
    windows
        panes

version


$ tmux -V
tmux 2.6

list


~> tmux ls
ebal: 1 windows (created Mon Aug  5 06:47:35 2019) [125x39] (attached)

new session


$ tmux new -s ebal

attach


$ tmux attach -t ebal

attach / detach


tmux new -s session_name
    creates a new tmux session named session_name
tmux attach -t session_name
    attaches to an existing tmux session named session_name
tmux switch -t session_name
    switches to an existing session named session_name
tmux list-sessions
    lists existing tmux sessions
tmux detach (prefix + d)
    detach the currently attached session

ReadOnly attach session


$ tmux attach -t session_ebal -r

synchronize panes


ctl + b


:setw synchronize-panes on


:setw synchronize-panes off

Capture Pane


ctrl+prefix a : capture-pane -S [lines]


will save the tmux pane into a buffer


and after that


ctrl+prefix  a : save-buffer /tmp/output


to save the buffer into a text file named output under /tmp directory


equally balance panes


Vertically

:select-layout even-vertical

prefix + alt + 2

Horizontally


:select-layout even-horizontal

prefix + alt + 1


zoom into a pane


prefix + z


send-keys


eg. session:ebal


~> tmux list-windows -t ebal |cut -d: -f1|xargs -I{} tmux send-keys -t ebal:{} clear C-m

reload config


prefix + :


:source-file ~/.tmux.conf

conf


$ vim ~/.tmux.conf


# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix


# Shift arrow to switch windows
bind -n S-Left  previous-window
bind -n S-Right next-window
bind -n S-Up new-window


# Control + Arrow keys to pane switching
bind -n C-Up select-pane -U 
bind -n C-Down select-pane -D 
bind -n C-Left select-pane -L 
bind -n C-Right select-pane -R 

# Vertical Split - Control + v
bind -n C-v split-window
# Horizontal Split- Control + h
bind -n C-h split-window -h



# Improve colors
set -g default-terminal 'screen-256color'

# Set scrollback buffer to 10000
set -g history-limit 10000

# Customize the status line
set -g status-fg  green
set -g status-bg  black