(One intermediate revision by the same user not shown)
Line 79: Line 79:
 
| ,
 
| ,
 
| Rename the current window
 
| Rename the current window
 +
|-
 +
| .
 +
| Renumber the window
 +
{{code|swap-window -s 3 -t 1}} to swap windows 3 to 1.
 
|}
 
|}
  
Line 122: Line 126:
 
# make scrolling with wheels work
 
# make scrolling with wheels work
 
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
 
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M                                                                                      
+
bind -n WheelDownPane select-pane -t= \; send-keys -M
 +
 
 +
# Move windows with C-b Left or C-b Right (arrow keys)
 +
# bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
 +
# bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
 +
bind Left swap-window -t -1
 +
bind Right swap-window -t +1
 +
 
 +
# Reload with 'Ctrl-b R'
 +
bind R source-file ~/.tmux.conf \; display-message "  Config reloaded..".
 +
bind S setw synchronize-panes \; display-message " Synchronize panes".
 +
 
 
}}
 
}}
  

Latest revision as of 10:02, 26 March 2020

tmux is a terminal multiplexer similar to Screen but with some cool features such as split panes.

Quick Usage[edit]

When starting tmux, you create a new session. Each session can have multiple windows (numbered 0..N). Each window can split into multiple panes.

Command Description
tmux ls Lists all tmux sessions
tmux new -s session-name Creates a new session named session-name
tmux a|attach N Attaches to an existing session
tmux a|attach -t session-name Attaches to an existing session by name
tmux kill-session -t session-name Kills a session by name
tmux kill N Kills a session by ID

Commands[edit]

All commands to tmux is prefixed with a key (Ctrl-b as opposed to Ctrl-a in screen).

General commands:

Command Description
d Detach from this session
$ Rename current session
s Lists all sessions
t Shows a clock in the current pane
? Shows key bindings
: Enters the tmux command prompt, where you can enter commands
[ Enter copy mode with. You can use Vim key bindings if you set the mode-keys in the settings (see below). Exit copy mode by pressing Enter.

Windows (tab) commands:

Command Description
c Creates a new window
w Lists windows
n Go to next window
p Go to previous window
& Kills the current window
, Rename the current window
. Renumber the window

swap-window -s 3 -t 1 to swap windows 3 to 1.

Panes (split) commands. Enable mouse (see below) to make switching and resizing panes easy.

Command Description
% Horizontal split (% is like 0/0, splits left/right)
" Vertical split
x Close pane
! Close all other panes
o Swap panes
q Show pane numbers
z 'Zooms' or maximizes the selected pane

To synchronize the input to all panes in the current window, enter :setw synchronize-panes. I bound this to Ctrl-b S for convenience in my .tmux.conf.

Configuration[edit]

Configuration can be set in ~/.tmux.conf file. Some useful settings are given below.

# Enable Vim key bindings in copy-mode
setw -g mode-keys vi

# Enable mouse, useful for selecting or resizing panes
set-option -g mouse on

# make scrolling with wheels work
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M

# Move windows with C-b Left or C-b Right (arrow keys)
# bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
# bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
bind Left swap-window -t -1
bind Right swap-window -t +1

# Reload with 'Ctrl-b R'
bind R source-file ~/.tmux.conf \; display-message "  Config reloaded..".
bind S setw synchronize-panes \; display-message " Synchronize panes".

See Also[edit]