forked from wklken/k-vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf
243 lines (194 loc) · 8.82 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#==========================================
# URL: https://github.com/wklken/k-tmux
# Author: wklken
# Version: 0.1
# Email: wklken@yeah.net
# ReadMe: README.md
# Donation: http://www.wklken.me/pages/donation.html
# Last_modify: 2015-08-06
#==========================================
# Dependecny:
# 1. brew install reattach-to-user-namespace
# 2. gem install tmuxinator
# 3. vim: christoomey/vim-tmux-navigator
#--------------------------- base config begin -------------------------------
# 全局设置
setw -g xterm-keys on
# set -g status-utf8 on # enable utf-8
set-option -g default-terminal "screen-256color" # use 256 colors
set-option -g history-limit 100000 # scrollback buffer n lines
set-option -g display-time 5000 #提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒
set-option -g repeat-time 1000 #控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒
set-window-option -g display-panes-time 1500
set-option -g repeat-time 0 # Allow the arrow key to be used immediately after changing windows
set-option -g renumber-windows on # window 0, 1, 2, remove 1, renumber to 0, 1
# Set window notifications
setw -g monitor-activity on
set -g visual-activity on
# use C-a, since it's on the home row and easier to hit than C-b
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
# bind a reload key: prefix+r
bind R source-file ~/.tmux.conf \; display-message "Config reloaded.."
# ssh-agent
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
# -------------------------------- session begin --------------------------------
bind -r ( switch-client -p
bind -r ) switch-client -n
# -------------------------------- session end --------------------------------
# -------------------------------- window begin --------------------------------
set-option -g base-index 1 #窗口的初始序号;默认为0,这里设置为1
set-window-option -g pane-base-index 1 # panes index start at 1, setw means set-window-option
set-window-option -g other-pane-height 25
set-window-option -g other-pane-width 80
# [prefix-c] 创建新窗口
bind-key c new-window
# [prefix-数字] 切换窗口
# [prefix-p] 切换窗口
# [prefix-t/T] 切换窗口
bind-key t next-window
bind-key T previous-window
# bind-key space next-window
# bind-key bspace previous-window
# [prefix-Ctrl-o] 窗口轮转
bind-key C-o rotate-window
# -------------------------------- window end --------------------------------
# -------------------------------- pane begin --------------------------------
# use vim-like keys for splits and windows
# v / s 竖直、水平分割window为pane
unbind '"'
unbind %
# 窗口切割 split windows like vim. - Note: vim's definition of a horizontal/vertical split is reversed from tmux's
# [prefix-v] / [prefix-s] 垂直/水平分割窗口
# bind-key v split-window -h
# bind-key s split-window -v
# key bindings for horizontal and vertical panes
# 键 [\|] 和 [_-] 少敲一个shift键
bind-key \ split-window -h -c '#{pane_current_path}'
bind-key - split-window -v -c '#{pane_current_path}'
# 窗口间切换
# [prefix-hjkl] pane之间移动
unbind-key h
bind-key h select-pane -L
unbind-key j
bind-key j select-pane -D
unbind-key k
bind-key k select-pane -U
unbind-key l
bind-key l select-pane -R
# smart pane switching with awareness of vim splits
# [Ctrl-hjkl] pane之间移动
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-l) || tmux select-pane -R"
# [Ctrl-l] 左右两个切 [Ctrl-\] 最近的两个切换
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys 'C-\\') || tmux select-pane -l"
bind C-l send-keys 'C-l'
# [prefix-q] 展示窗口数字并选择跳转
bind-key q display-panes
# bind-key a last-pane # 绑什么好?
# 窗口大小调整
# resize panes using PREFIX H, J, K, L
bind H resize-pane -L 5
bind J resize-pane -D 5
bind K resize-pane -U 5
bind L resize-pane -R 5
# layout
# [prefix-space]
# bind-key + select-layout main-horizontal
# bind-key = select-layout main-vertical
# -------------------------------- pane end --------------------------------
# -------------------------------- move/copy/paste begin --------------------------------
# use vi mode
# vi is good 把 Tmux 设为 vi 模式,使其与 Vim 的操作更加接近
setw -g mode-keys vi
# [ 进入复制,space键开始选择问题 方向键移动, 回车复制 ] 黏贴
bind-key [ copy-mode
bind-key ] paste-buffer
# Copy and paste like in vim
# p 换成paste
unbind p
bind p paste-buffer
# # the following vi-copy bindings match my vim settings
# # see https://github.com/gpakosz/.vim.git
# # Setup 'v' to begin selection as in Vim
# # bind -t vi-copy v begin-selection
# bind-key -t vi-copy v begin-selection
# bind -t vi-copy C-v rectangle-toggle
# # bind -t vi-copy y copy-selection
# bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# bind -t vi-copy Escape cancel
# bind -t vi-copy H start-of-line
# bind -t vi-copy L end-of-line
# # Update default binding of `Enter` to also use copy-pipe
# unbind -t vi-copy Enter
# bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# tmux 2.5
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi C-v send -X rectangle-toggle
bind-key -T copy-mode-vi y send -X copy-pipe "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi Escape send -X cancel
bind-key -T copy-mode-vi H send -X start-of-line
bind-key -T copy-mode-vi L send -X end-of-line
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi Enter send -X copy-pipe "reattach-to-user-namespace pbcopy"
# for osx
# Enable native Mac OS X copy/paste 对于mac用户,可以复制到系统剪贴板
set-option -g default-command "/bin/bash -c 'which reattach-to-user-namespace >/dev/null && exec reattach-to-user-namespace $SHELL -l || exec $SHELL -l'"
# -------------------------------- move/copy/paste end --------------------------------
# -------------------------------- mouse begin --------------------------------
# mouse behavior
# setw -g mode-mouse on
# set -g mouse-select-pane on
# set -g mouse-resize-pane on
set -g mouse off
# -------------------------------- mouse end --------------------------------
# -------------------------------- status line begin --------------------------------
# 颜色
# set-option -g status-bg black
# set-option -g status-fg white
set -g status-bg '#4e4e4e'
set -g status-fg '#bbbbbb'
set -g status-left-style fg='#bbbbbb',bg='#4e4e4e'
set -g status-right-style fg='#bbbbbb',bg='#4e4e4e'
set -g status-left-length 90
set -g status-right-length 60
# 对齐方式
set-option -g status-justify centre
# 左下角
# set-option -g status-left '#[bg=black,fg=green][#[fg=cyan]#S#[fg=green]]'
set-option -g status-left "S-#S:W-#I:P-#P"
# 窗口列表
setw -g automatic-rename on
# set-window-option -g window-status-current-fg magenta
set-window-option -g window-status-format '#[dim]#I:#[dim]#W#[fg=grey,dim]'
set-window-option -g window-status-current-format '[#[fg=white,bold]#I#[fg=white,bold]:#[fg=white,bold]#W#[fg=dim]]'
# 右下角
set -g status-right '#[fg=green][#[fg=white]%m-%d %H:%M#[fg=green]]'
# -------------------------------- status line end --------------------------------
# -------------------------------- color begin --------------------------------
# pane border colors
set-option -g pane-active-border-style fg='#55ff55'
set-option -g pane-border-style fg='#555555'
# set -g pane-border-fg colour245
# set -g pane-active-border-fg colour39
# -------------------------------- color end --------------------------------
#--------------------------- base config end -------------------------------
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
# tmux-resurrect
set -g @resurrect-save-bash-history 'on'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-strategy-vim 'session'
# set -g @resurrect-save 'S'
# set -g @resurrect-restore 'R'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'