forked from farzadghanei/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
261 lines (223 loc) · 10.1 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
251
252
253
254
255
256
257
258
259
260
261
# 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
# 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 -g default-terminal "screen-256color"
# Split horiziontal and vertical splits, instead of % and "
# Also open them in the same directory
bind-key v split-window -h -c '#{pane_current_path}'
bind-key s split-window -v -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!"
# Clear history!
# Clear tmux history with Ctrl-K
# Clean bash history with Ctrl-L
bind -n C-k clear-history
# 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\; run "tmux save -|pbcopy >/dev/null 2>&1"
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# Copy text with mouse selection without pressing any key
# NOTE(timon): on linux, make sure you have installed the following programs: xclip, xsel and wl-clipboard
# TODO(timon): support for Windows and Windows Subsystem for Linux
if-shell "uname | grep -q Darwin" 'bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel\; run "tmux save -|pbcopy"'
if-shell "echo $XDG_SESSION_TYPE | grep -q 'x11'" 'bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel\; run "tmux save -|xsel --clipboard --input"'
if-shell "echo $XDG_SESSION_TYPE | grep -q 'wayland'" 'bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel\; run "tmux save -|wl-copy"'
# 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.
setw -g pane-active-border-style fg=colour63,bg=default
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 -n C-S-Left resize-pane -L 10
bind-key -n C-S-Right resize-pane -R 10
bind-key -n C-S-Up resize-pane -U 5
bind-key -n C-S-Down resize-pane -D 5
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
# This tmux statusbar config was created by tmuxline.vim
# on Wed, 25 Nov 2015
set -g status "on"
set -g status-interval 1
set -g status-bg "colour236"
set -g status-justify "left"
set -g status-position "top"
set -g status-left-length "100"
set -g status-right-length "100"
set -g status-left "#[fg=colour22,bg=colour148,bold] #S #[fg=colour148,bg=colour236]"
set -g status-right "#{prefix_highlight}#[fg=colour0,bg=colour220] #(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD || echo no git) #[fg=colour250,bg=colour240] %d %b %H:%M:%S #[fg=colour241,bg=colour252] #U@#H #[fg=colour252,bg=colour240] #(echo $XDG_SESSION_TYPE) "
setw -g window-status-separator ""
setw -g window-status-format "#[fg=colour245,bg=colour236] #I #[fg=colour245,bg=colour236]#W "
setw -g window-status-current-format "#[fg=colour236,bg=colour240,nobold,nounderscore,noitalics]#[fg=colour231,bg=colour240] #I #[fg=colour231,bg=colour240]#{?window_zoomed_flag,#[fg=green][],}#W #[fg=colour240,bg=colour236,nobold,nounderscore,noitalics]"
# Nix' home-manager does its own plugin management, so we only do this when not-nix.
if-shell -b '[ -e ~/.tmux/plugins/tpm/tpm ]' {
# List of plugins
# see this https://github.com/tmux-plugins/tpm to installation
# @NOTE(timon): Press C-f + I (yes, capital I) to install TPM plugins
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'
set -g @plugin 'soyuka/tmux-current-pane-hostname'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
# Make sure to init tpm:
# - mkdir ~/.tmux/plugins
# - git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
run -b '~/.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.
###############################################