-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmuxConf
229 lines (191 loc) · 7.93 KB
/
tmuxConf
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
# INSTALL
# cp tmuxconf ~/.tmux.conf
#
# Set prefix key to c-f instead of default c-b
unbind C-b
set -g prefix C-f
bind C-f send-prefix
set-environment -g PATH "/usr/local/bin:/bin:/usr/bin"
set-option -g default-shell /usr/local/bin/fish
# toogle last window by hitting again C-f
bind-key C-f last-window
# if multiple clients are attached to the same window, maximize it to the
# bigger one
set-window-option -g aggressive-resize
# Start windows and pane numbering with index 1 instead of 0
set -g base-index 1
setw -g pane-base-index 1
# re-number windows when one is closed
set -g renumber-windows on
# word separators for automatic word selection
setw -g word-separators ' @"=()[]_-:,.'
setw -ag word-separators "'"
# Show times longer than supposed
set -g display-panes-time 2000
# tmux messages are displayed for 4 seconds
set -g display-time 4000
# {n}vim compability
set-option -ga terminal-overrides ",xterm-256color:Tc"
set -g default-terminal "screen-256color"
# Split horiziontal and vertical splits, instead of % and ". We also open them
# in the same directory. Because we use widescreens nowadays, opening a
# vertical split that takes half of the screen is not worth. For vertical we
# only open 90 lines width, for horizontal it's 20 columns.
bind-key v split-window -h -l 90 -c '#{pane_current_path}'
bind-key s split-window -v -l 20 -c '#{pane_current_path}'
# Pressing Ctrl+Shift+Left (will move the current window to the left. Similarly
# right. No need to use the modifier (C-b).
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
# Source file
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Update default binding of `Enter` and `Space to also use copy-pipe
unbind -T copy-mode-vi Enter
unbind -T copy-mode-vi Space
bind-key -T edit-mode-vi Up send-keys -X history-up
bind-key -T edit-mode-vi Down send-keys -X history-down
# setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
# copy text with `y` in copy mode
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# copy text with mouse selection without pressing any key
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel
# emacs key bindings in tmux command prompt (prefix + :) are better than
# vi keys, even for vim users
set -g status-keys emacs
# focus events enabled for terminals that support them
set -g focus-events on
# Sync panes (Send input to all panes in the window). When enabled, pane
# borders become red as an indication.
bind C-s if -F '#{pane_synchronized}' \
'setw synchronize-panes off; \
setw pane-active-border-style fg=colour63,bg=default; \
setw pane-border-format " #P "' \
'setw synchronize-panes on; \
setw pane-active-border-style fg=red; \
setw pane-border-format " #P - Pane Synchronization ON "'
# Faster command sequence
set -s escape-time 0
# Have a very large history
set -g history-limit 1000000
# Mouse mode on
# set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set -g mouse on
# Set title
set -g set-titles on
set -g set-titles-string "#T"
# Equally resize all panes
bind-key = select-layout even-horizontal
bind-key | select-layout even-vertical
# Resize panes
bind-key J resize-pane -D 10
bind-key K resize-pane -U 10
bind-key H resize-pane -L 10
bind-key L resize-pane -R 10
# Select panes
# NOTE(arslan): See to prevent cycling https://github.com/tmux/tmux/issues/1158
bind-key j select-pane -D
bind-key k select-pane -U
bind-key h select-pane -L
bind-key l select-pane -R
# Disable confirm before killing
bind-key x kill-pane
# List of plugins
# see this https://github.com/tmux-plugins/tpm to installation
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# The followings are not any kind of setting for Tmux, but crucial to my
# own productivity. Setting them up is really pain, and I probably going to
# forget it. So I'm just putting them here again.
######## iTerm + Tmux key integration #########
# First of all, iTerm can send hex codes for shortcuts you define. So for
# example you can send a hex code for the shortcut "c-f v" which in my case
# opens a vertical pane (see setting above). The hex code for this combination
# is: 0x06 0x76. There are many cases to find it out. One of them is the tool
# 'xxd'
# If you run "xxd -psd" and hit "c-f v" and then enter and finally c-c to exit
# , it outputs the following:
#
# $ xxd -psd
# ^Fv
# 06760a^C
#
# What matters is the sequence 06760a^C where:
#
# 06 -> c-f
# 76 -> v
# 0a -> return
# ^C -> c-c
#
# From here, we know that 0x06 0x76 corresponds to "c-f v".
#
# Finally, inside the iTerm2 Key settings, I'm adding just various shortcuts,
# such as cmd-j, cmd-left, etc.. , select the option "send hex code" and the
# enter the hex code which I want to be executed, hence the tmux sequence. So
# when I press CMD + d in iterm, I send the sequence 0x06 0x76,
# which tmux inteprets it as opening a new pane.
###############################################
######## Alacritty + Tmux key integration #########
# First of all, Alacritty can send hex codes for shortcuts you define. So for
# example you can send a hex code for the shortcut "c-f v" which in my case
# opens a vertical pane (see setting above). The hex code for this combination
# is: 0x06 0x76. There are many cases to find it out. One of them is the tool
# 'xxd'
# If you run "xxd -psd" and hit "c-f v" and then enter and finally c-c to exit
# , it outputs the following:
#
# $ xxd -psd
# ^Fv
# 06760a^C
#
# What matters is the sequence 06760a^C where:
#
# 06 -> c-f
# 76 -> v
# 0a -> return
# ^C -> c-c
#
# From here, we know that 0x06 0x76 corresponds to "c-f v".
#
# Next step is to add a line to 'key_binding' setting in Alacritty:
#
# - { key: D, mods: Command, chars: "\x06\x76" }
#
# That's it! The followings are the ones that I'm using:
#
# key_bindings:
# - { key: D, mods: Command, chars: "\x06\x76" }
# - { key: D, mods: Command|Shift, chars: "\x06\x73" }
# - { key: W, mods: Command, chars: "\x06\x78" }
# - { key: H, mods: Command, chars: "\x06\x68" }
# - { key: J, mods: Command, chars: "\x06\x6a" }
# - { key: K, mods: Command, chars: "\x06\x6b" }
# - { key: L, mods: Command, chars: "\x06\x6c" }
# - { key: T, mods: Command, chars: "\x06\x63" }
# - { key: Key1, mods: Command, chars: "\x06\x31" }
# - { key: Key2, mods: Command, chars: "\x06\x32" }
# - { key: Key3, mods: Command, chars: "\x06\x33" }
# - { key: Key4, mods: Command, chars: "\x06\x34" }
# - { key: Key5, mods: Command, chars: "\x06\x35" }
# - { key: Key6, mods: Command, chars: "\x06\x36" }
# - { key: Key7, mods: Command, chars: "\x06\x37" }
# - { key: Key8, mods: Command, chars: "\x06\x38" }
# - { key: Key9, mods: Command, chars: "\x06\x39" }
# - { key: Left, mods: Command, chars: "\x06\x48" }
# - { key: Down, mods: Command, chars: "\x06\x4a" }
# - { key: Up, mods: Command, chars: "\x06\x4b" }
# - { key: Right, mods: Command, chars: "\x06\x4c" }
#
# Finally, inside the iTerm2 Key settings, I'm adding just various shortcuts,
# such as cmd-j, cmd-left, etc.. , select the option "send hex code" and the
# enter the hex code which I want to be executed, hence the tmux sequence. So
# when I press CMD + d in iterm, I send the sequence 0x06 0x76,
# which tmux inteprets it as opening a new pane.
###############################################