tmux 配置

起因:
在ubuntu下配置tmux
配置文件如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

# 配置prefix键
set -g prefix C-a
unbind-key C-b

#更改默认序号
set -g base-index 1
setw -g pane-base-index 1

# 配置文件重载和编辑快捷键
bind-key r source-file ~/.tmux.conf\; display-message "Config reloaded"
bind e new-window -n ".tmux.conf" "vim ~/.tmux.conf"

# 配置分割面板快捷键
bind-key | split-window -h
bind-key - split-window

<!-- more -->

# 面板间移动的快捷键
bind-key l select-pane -R
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key C-l select-window -l

# 面板大小调整
bind-key L resize-pane -R 5
bind-key H resize-pane -L 5
bind-key K resize-pane -U 5
bind-key J resize-pane -D 5

#bind m run 'old=$(tmux show -gv mouse);new=""; if [ "$old" = "on" ]; then new="off"; else new="on"; fi; tmux set -g mouse $new; tmux display "mouse: $new"'
# 启用鼠标
set-option -g mouse on
## disable mouse control by default - change 'off' to 'on' to enable by default.
#setw -g mode-mouse off
#set-option -g mouse-resize-pane off
#set-option -g mouse-select-pane off
#set-option -g mouse-select-window off
#
## set mouse on with prefix m
#bind m \
#set -g mode-mouse on \;\
#set -g mouse-resize-pane on \;\
#set -g mouse-select-pane on \;\
#set -g mouse-select-window on \;\
#display 'Mouse: ON'
#
## set mouse off with prefix M
#bind M \
#set -g mode-mouse off \;\
#set -g mouse-resize-pane off \;\
#set -g mouse-select-pane off \;\
#set -g mouse-select-window off \;\
#display 'Mouse: OFF'
#

# 调整历史记录数量
set -g history-limit 10000

# 复制模式
setw -g mode-keys vi
#bind-key -Tcopy-mode-vi 'v' send -X begin-selection
#bind-key -Tcopy-mode-vi 'y' send -X copy-selection
unbind p
bind p paste-buffer
bind b choose-buffer

set -g default-terminal "screen-256color" # 颜色支持
setw -q -g utf8 on # utf8 支持
set -q -g status-utf8 on # tmux < 2.2
setw -g automatic-rename on # 自动重命名窗口
set -g renumber-windows on # 关闭窗口的时候重新计算窗口index
set -g display-time 4000 # tmux 消息提示时间为4秒
set -g status-right "#h %m-%d %R %a"

## plugin manager
#tmux 插件列表
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
set -g @plugin 'tmux-plugins/tmux-yank'

#plugin settings
set -g @resurrect-save-bash-history 'on'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-strategy-vim 'session'


#将这一行插入.tmux.conf最底部
run '~/.tmux/plugins/tpm/tpm'

配置文件参考:
http://gitbook.cn/books/5a362ddc2edf834ef46b6415/index.html
http://blog.jobbole.com/87584/
http://blog.csdn.net/guoer9973/article/details/46560761