-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.tmux.conf
250 lines (188 loc) · 7.54 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
244
245
246
247
248
249
250
# vim: fdm=marker
#
# QUICK TUTORIAL ON THESE MAPPINGS
#
# All commands begin with C-a (i.e., ctrl-a).
# All the mappings you will need:
#
# C-a n New tab (called a "window" in tmux)
# C-a c Close the current tab
# C-a m Move the current tab
# C-a r Rename the current tab
#
# C-a v Vertical split
# C-a s Horizontal split
#
# C-a h Move left one split (called a "pane" in tmux)
# C-a l Move right one split
# C-a j Move up one split
# C-a k Move down one split
#
# C-a C-h Move left one tab
# C-a C-l Move right one tab
#
# C-a C-a Move to last tab
#
# There are more mappings (read the rest of the file)
#
# Settings {{{
# default shell: bash
set -g default-command /bin/bash
set -g default-shell /bin/bash
# basic settings
set-window-option -g xterm-keys on # for vim
set-window-option -g mode-keys vi # vi key
# GNU-Screen compatible prefix
set -g prefix2 C-a
bind C-a send-prefix -2
# expect UTF-8 (tmux < 2.2)
set -q -g status-utf8 on
setw -q -g utf8 on
# 256 colors
set -g default-terminal "screen-256color"
# More history
set -g history-limit 100000
# Open ~/.tmux.conf in vim and reload settings on quit
unbind e
bind e new-window -n '~/.tmux.conf' "sh -c '\${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display \"~/.tmux.conf sourced\"'"
# reload configuration
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
# This is necessary for vim to work properly
set-option -sg escape-time 0
# -- display -------------------------------------------------------------------
# Start numbering windows at 1
set -g base-index 1
# make pane numbering consistent with windows
setw -g pane-base-index 1
# set terminal title
set -g set-titles on
set -g set-titles-string '#h ❐ #S ● #I #W'
# Rename windows
setw -g automatic-rename on
# renumber windows when a window is closed
set -g renumber-windows on
# Monitor activity, but without a big status message
setw -g monitor-activity on
set -g visual-activity off
# Better resizing
setw -g aggressive-resize on
# Even vertical split
bind C-v select-layout even-vertical
# Even vertical split
bind C-h select-layout even-horizontal
# Show messages for slightly longer
set -g display-time 1000
set -g display-panes-time 800
# Sane scrolling
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# -- navigation ----------------------------------------------------------------
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# vim bindings
setw -g mode-keys vi
setw -g status-keys vi
# find session
bind C-f command-prompt -p find-session 'switch-client -t %%'
# Mouse interaction
set -g mouse on
# Use m and M to toggle mouse mode on and off respectively
unbind m
unbind M
bind-key m \
set -w mouse on \;\
display 'Mouse mode on'
bind-key M \
set -w mouse off \;\
display 'Mouse mode off'
# Confirm before detatch
bind d confirm-before "detach"
# Move current window to Top position
bind t swap-window -t 1
bind C-t swap-window -t 1
# maximize current pane
bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane "#{session_name}" #D'
# pane resizing
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2
# Navigate panes with hjkl (no ctrl)
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind > swap-pane -D # swap current pane with the next one
bind < swap-pane -U # swap current pane with the previous one
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Use shift + arrow key to move between windows in a session
bind -n S-Left previous-window
bind -n S-Right next-window
# split panes using | and -
bind | split-window -h -c "#{pane_current_path}"
bind \\ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind _ split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# -- status -------------------------------------------------------------------
# Refresh status line every 5 seconds
set -g status-interval 5
# Set the background color
set -g status-bg colour8
#set -g window-status-activity-attr bold
#set-window-option -g window-status-bg black
#set-window-option -g window-status-current-bg black
#set-window-option -g window-status-current-format '#[fg=yellow][#I]#[fg=yellow] #W'
#set-window-option -g window-status-format '#[fg=brightgreen][#I]#[fg=brightgreen] #W'
#Set the left and right status
set -g status-left '#[bg=yellow]#[fg=black]#{?client_prefix,#[bg=green],} ❐ #S #[bg=colour8]#[fg=yellow]#{?client_prefix,#[fg=green],}#{?window_zoomed_flag, 🔍 ,} '
set -g status-right '#[fg=green,bold]#[bg=green,bold]#[fg=colour220] #(echo $USER) #[fg=blue]#[bg=blue]#[fg=cyan,bold] #h'
# customize how windows are displayed in the status line
set -g window-status-current-format "#[fg=colour8]#[bg=cyan]#[fg=colour18]#[bg=cyan] #I* #[fg=colour18] #W #[fg=cyan,bold]#[bg=colour8]"
set -g window-status-format "#[fg=brightgreen]#[bg=colour8]#I#[fg=brightgreen] #W"
# messages
set -g message-style bg=green
# -- copy mode -----------------------------------------------------------------
bind Enter copy-mode # enter copy mode
run -b 'tmux bind -t vi-copy v begin-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi v send -X begin-selection 2> /dev/null || true'
run -b 'tmux bind -t vi-copy C-v rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi C-v send -X rectangle-toggle 2> /dev/null || true'
run -b 'tmux bind -t vi-copy y copy-selection 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi y send -X copy-selection-and-cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy Escape cancel 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi Escape send -X cancel 2> /dev/null || true'
run -b 'tmux bind -t vi-copy H start-of-line 2> /dev/null || true'
run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true'
# copy to Mac OSX clipboard
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
# copy to X11 clipboard
if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"'
# copy to Windows clipboard
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"'
if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"'
# -- buffers -------------------------------------------------------------------
bind b list-buffers # list paste buffers
bind p paste-buffer # paste from the top paste buffer
bind P choose-buffer # choose which buffer to paste from
# -- functions -------------------------------------------------------------------
# -- plugins --------------------------------------------------------------------
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'