/
tmux.conf
174 lines (124 loc) · 5.08 KB
/
tmux.conf
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#### 一些常用的快捷键
# c create window
# | vertically split windows as pane
# - horizonlly split windows as pane
#
# n/p go to next/previous window
#
# x kill pane
# X kill window
# z kill session
# Z kill server
#
# d detach session, will be back to shell, use "tmux attach" to be back to tmux
# D select session to detach
# s select and switch to session
#### General 通用配置
set -g prefix C-w #设置命令为ctrl-w触发prefix
unbind C-b #解绑ctrl-b
bind C-w send-prefix #设置预命令为prefix
# set -g default-terminal "screen-256color"
set -g display-time 5000
set -g history-limit 65535
set -sg escape-time 1
# enable vi key-binding mode 使用vi按键模式
setw -g mode-keys vi
set-option -g status-keys vi
set-window-option -g mode-keys vi
# enable utf-8 support, comment it if tmux > 2.2
# set-window-option -g utf8 on
# set -g status-utf8 on
# Set the base index for windows and pane to 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
#### mouse support - set to on if you want to use the mouse
## for tmux > v2.1, use this section
set -g mouse on
# For mouse wheel scrolling as from tmux 2.1 try adding one or both of these to ~/.tmux.conf
bind -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
## for tmux < v2.1, use this section
# set -g mode-mouse on
# set -g mouse-select-pane on
# set -g mouse-resize-pane on
# set -g mouse-select-window on
#### status-bar && color 状态栏及颜色配置
# set-option -g status-utf8 on
set -g status-interval 10
## notify when window contain changed
setw -g monitor-activity on
set -g visual-activity off
# S/W/P -> Session/Window/Pane
set -g status-left "#[bg=cyan,bold]S/W/P[#S/#I/#P]"
# set -g status-left "Session: #S #I #P"
set -g status-left-length 30
# set-option -g status-right "#[fg=cyan]#(date +%H:%M' ')" # right part: time lisk 23:59
set -g status-right "#[bg=yellow,bold]#(hostname)#[bg=blue,fg=white]%y/%m/%d/%a#[bg=green,fg=black]%H:%M"
# set-option -g status-right-length 10 # more space left for center part (window names)
set -g status-justify centre # center the windows list
# status-bar main color
set -g status-fg black
set -g status-bg white
# window list
setw -g window-status-style fg=blue,bg=default
# setw -g window-status-attr dim
setw -g window-status-format "[#I]#W"
# current window
setw -g window-status-current-style fg=white,bg=red
# setw -g window-status-current-attr bright
setw -g window-status-current-format "[#I]#W"
# pane colors
set -g pane-border-style fg=white,bg=black
set -g pane-active-border-style fg=green
# set -g pane-active-border-bg yellow
# Command / message line
set -g message-style fg=black,bg=yellow
# set -g message-attr bright
#### Key-Binding 按键映射配置
unbind C-h
# control sessions/server
bind-key z kill-session
bind-key Z kill-server
bind-key X kill-window
# split window
unbind '"'
bind - splitw -v # vertical split (prefix -)
unbind %
bind | splitw -h # horizontal split (prefix |)
# pane selection
bind k select-pane -U #选择上窗口
bind j select-pane -D #选择下窗口
bind h select-pane -L #选择左窗口
bind l select-pane -R #选择右窗口
# pane resize
bind K resize-pane -U 5 #窗格上移5 (大写,即shift-k一起按)
bind J resize-pane -D 5 #窗格下移5
bind H resize-pane -L 5 #窗口左移5
bind L resize-pane -R 5 #窗口右移5
bind -r K resize-pane -U 5 #窗口重复操作
bind -r J resize-pane -D 5 #窗口重复操作
bind -r H resize-pane -L 5 #窗口重复操作
bind -r L resize-pane -R 5 #窗口重复操作
bind ^u swapp -U #与上窗格交换 (Ctrl-u)
bind ^d swapp -D #与下窗格交换 (Ctrl-u)
# 重新加载配置文件
bind r source-file ~/.tmux.conf \; display "Tmux Configuration File Reloaded Successfully !"
# bind r source-file /etc/tmux.conf \; display "Tmux Configuration File Reloaded Successfully !"
# fix mouse scroll problem with MobaXterm
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
#### 像vi一样复制
# 所有复制都会被记录在缓冲区,输入#或tmux list-buffers查看,=也可以选择粘贴缓冲区
unbind [
bind Escape copy-mode #绑定Esc进入复制模式
#unbind p #解绑p
bind P paste-buffer #绑定P为粘贴
# bind -t vi-copy 'v' begin-selection #绑定v为选择
# bind -t vi-copy 'y' copy-selection #绑定y为复制
## Though the above will only scroll one line at a time, add this solution to scroll an entire page instead
# bind -t vi-copy WheelUpPane page-up
# bind -t vi-copy WheelDownPane page-down
# bind -t emacs-copy WheelUpPane page-up
# bind -t emacs-copy WheelDownPane page-down
#### Working with the Clipboard on Linux
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"