Profiles
System-wide configuration file is /etc/tmux.conf , and personal configuration file in ~ / .tmux.conf .
A profile can define new keyboard shortcuts, custom window, pane layout.
Binding the CAPS LOCK key to CTRL key
On OS X: Open Keyboard preference panel
-> System Preference
, press the Modifier
key, then CAPS LOCK
the read operation Control
.
In Linux, you need to be modified for the keyboard configuration file:
sudo vi /etc/default/keyboard
Locate the XKBOPTIONS beginning of the line, add ctrl:nocaps
the CAPS LOCK
become another CTRL
key, or add ctrl:swapcaps
the CAPS LOCK
key and the CTRL
two key functions of mutual exchange. For example, the modified content may be:
XKBOPTIONS="lv3:ralt_alt,compose:menu,ctrl:nocaps"
Then run:
sudo dpkg-reconfigure keyboard-configuration
For details, see Emacs WIKI .
Define a much easier by the PREFIX
CTRL-b
Not very good press, if you have CAPS LOCK redefined as CTRL, CTRL-a
will be better by the multi (GNU-SCreen of PREFIX is CTRL-a
).
.tmux.conf configuration command is the SET-Option , or abbreviated as SET .
The tmux PREFIX redefined:
set -g prefix C-a
Here -g
the switch is global global meaning, represents the setting value is used for all sessions tmux.
You can use unbind-key
command, or short of unbind
the previous command to unbind, such as canceled before PREFIX binding CTRL-b
:
unbind C-b
Because the re-binding, before binding is automatically canceled, so in this case, there is no need to use unbind
.
When the configuration file .tmux.conf modified, tmux does not automatically re-read and execute, you need tmux session, use the shortcut key PREFIX :
to enter the command mode, and perform source-file ~/.tmux.conf
to reload the configuration file.
Send commands to modify the default delay duration
Tmux send commands to the default length very short delay may cause a conflict with editors such as Vim.
Long delay time can increase more, in order to improve the responsiveness of operation:
set -sg escape-time 1
The default window is numbered starting from 0, since the arrangement position of the keyboard 1 and 0 ,, far better correlation window arranged and numbered from 1:
set -g base-index 1
set
Command is a configuration command for a session, and configuration commands for that window set-window-option
, or abbreviated setw
. As the window pane is the thing, the default number you want to pane is also set to start at 1, you should use setw
the command:
setw -g pane-base-index 1
Custom buttons, and a user input command
Most tmux shortcut keys are too long or difficult to operate. Should be commonly used shortcut keys re-set.
Creating a shortcut to reload the configuration file
After each modify the configuration file, need to be performed before source-file ~/.tmux.conf
, this command can be defined as a shortcut PREFIX r
:
bind r source-file ~/.tmux.conf
When reloading, preferably have a message alert, can display
output alert message in the status bar command. bind
Command can bind multiple commands with command between each \;
separately, such as:
bind r source-file ~/.tmux.conf \; display "Reloaded!"
Such binding when using the required prefix, if not the prefix, then:
bind-key -n C-r source-file ~/.tmux.conf
PREFIX sent to the application in the session
CTRL-a
Also Vim, Bash shortcuts, it is necessary to set up a shortcut to send to other applications CTRL-a
:
bind C-a send-prefix
After binding, with only two CTRL-a
will be able to send to the other applications CTRL-a
of.
Pane split command
The default split command hard to remember, bind shortcuts can image memory:
bind | split-window -h #水平分隔
bind - split-window -v
Move between panes
Default inter-pane can PREFIX o
cycle through, or with a PREFIX 方向键
switch. Referring Vim, for switching hjkl:
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
Simultaneously with the setting PREFIX CTRL-h
and PREFIX CTRL-l
switching between the moving window:
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
Here -r
the switch is repeatable repeatable meaning, represents only once the PREFIX, optionally followed by several successive key bindings. The default time interval is 500 milliseconds, may be provided repeat-time
to modify.
Design changes the size of the pane
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
Disabling mouse
Tmux 2.1 in the following versions:
setw -g mode-mouse off
In tmux 2.1 and above:
setw -g mouse off
Look and feel
Color scheme
Ensure Tmux and terminals support 256 colors.
In the terminal test supports 256 colors:
$wget http://www.vim.org/scripts/download_script.php?src_id=4568 -O colortest.pl
$perl colortest.pl -w
On Linux, you might need to add in the .bashrc:
[ -z "$TMUX" ] && export TERM=xterm-256color
Mac Snow Leopard end application supports only 16 colors, the color must be installed to support more iTerm2 in iTerm2, open default profile
, will be Terminal mode
modified xterm-256color
, while ensuring that the terminal supports UTF-8.
To tmux can display 256 colors:
set -g default-terminal "screen-256color"
Change the color
Modify status bar color
set -g status-fg white
set -g status-bg black
Modify window list color
setw -g window-status-fg cyan
setw -g window-status-bg default
setw -g window-status-attr dim
setw -g window-status-current-fg white
setw -g window-status-current-bg red
setw -g window-status-current-attr bright
The modification pane divider bar colors
set -g pane-border-fg green
set -g pane-border-bg black
set -g pane-active-border-fg white
set -g pane-active-border-bg yellow
Custom command line
set -g message-fg white
set -g message-bg black
set -g message-attr bright
Custom status bar
The status bar Supported Variables
Variable | Description
----------------- |
H | local host name
h | free domain name to the host name of the master
F | current window sign
l | index number of the current window
P | index number of the current pane
S | current session name
T | current window title
W | name of the current window
| # Character
The first line of output Shell command | (shell-command)
[Attributes] | color or attribute value
to sum up
Command Summary
Command | Description
---------------------------------- |
the SET -g prefix Ca | set PREFIX key
set -sg escape-time n | PREFIX key press is provided, the number of milliseconds to wait key.
source-file [file] | reload the configuration file
bind Ca send-prefix | Other applications will be sent twice PREFIX PREFIX key combination to
bind-key [key] [command ] | create shortcuts to perform the specified command can be abbreviated as the bind
the bind-key -r [key] [the command] | create shortcuts to perform the specified command can be abbreviated to bind, the shortcut key is pressed after a PREFIX, multiple continuous type
unbind-key [key] | cancel shortcut key bindings, may be abbreviated as the unbind
the display or the display-message | information displayed in the status bar
set-option [flags] [option ] [value] | session settings used -g switch to all sessions
set-window-option [option] [value] | property setting window
set-a | set value is added on an existing option, without replacing
Pragmatic Tmux from the configuration file:
# workflows/tmux.conf
# Our .tmux.conf file
# Setting the prefix from C-b to C-a
set -g prefix C-a
# Free the original Ctrl-b prefix keybinding
unbind C-b
#setting the delay between prefix and command
set -sg escape-time 1
# Ensure that we can send Ctrl-A to other apps
bind C-a send-prefix
# Set the base index for windows to 1 instead of 0
set -g base-index 1
# Set the base index for panes to 1 instead of 0
setw -g pane-base-index 1
# Reload the file with Prefix r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# splitting panes
bind | split-window -h
bind - split-window -v
# moving between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Quick pane selection
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# mouse support - set to on if you want to use the mouse
setw -g mode-mouse off
set -g mouse-select-pane off
set -g mouse-resize-pane off
set -g mouse-select-window off
# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# set the status line's colors
set -g status-fg white
set -g status-bg black
# set the color of the window list
setw -g window-status-fg cyan
setw -g window-status-bg default
setw -g window-status-attr dim
# set colors for the active window
setw -g window-status-current-fg white
setw -g window-status-current-bg red
setw -g window-status-current-attr bright
# pane colors
set -g pane-border-fg green
set -g pane-border-bg black
set -g pane-active-border-fg white
set -g pane-active-border-bg yellow
# Command / message line
set -g message-fg white
set -g message-bg black
set -g message-attr bright
# Status line left side
set -g status-left-length 40
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
set -g status-utf8 on
# Status line right side
# 15% | 28 Nov 18:15
set -g status-right "#(~/battery Discharging) | #[fg=cyan]%d %b %R"
# Update the status bar every sixty seconds
set -g status-interval 60
# Center the window list
set -g status-justify centre
# enable vi keys.
setw -g mode-keys vi
# Open panes in the same directory using the tmux-panes script
unbind v
unbind n
bind v send-keys " ~/tmux-panes -h" C-m
bind n send-keys " ~/tmux-panes -v" C-m
# Maximize and restore a pane
unbind Up
bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
unbind Down
bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp
# Log output to a text file on demand
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"
Resources: