-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_tmux.conf.tmpl
229 lines (173 loc) Β· 9.55 KB
/
dot_tmux.conf.tmpl
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
# -*-mode:sh-*- vim:ft=tmux
# ~/.tmux.conf
# =============================================================================
# Extra options for tmux terminal multiplexer.
#
# Sources:
# https://github.com/bravoecho/dotfiles/blob/main/dotfiles/tmux.conf
{{- /* This file supports Go's text/template language. */}}
# ===============
# === Colours ===
# ===============
# selection highlight
set-option -g mode-style "bg=colour8 fg=colour15"
# tmux command prompt
set-option -g message-style "bg=colour0 fg=default"
set-option -g message-command-style "bg=colour0 fg=colour15"
# ================
# === Versions ===
# ================
# The tmux development team will not support backward compatibility, nor will
# they adopt a version numbering scheme that highlights which versions contain
# breaking changes.
# Store the current tmux version in an environment variable to support
# conditional settings.
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
# This requires a version of `sort' that supports the `-V' option (sort by
# version numbers).
run-shell 'tmux setenv -g TMUX_GTE_2_1 $([ "${TMUX_VERSION}" = $(echo "${TMUX_VERSION}\n2.1" | sort -rV | head -n1) ] && echo 1)'
run-shell 'tmux setenv -g TMUX_GTE_2_2 $([ "${TMUX_VERSION}" = $(echo "${TMUX_VERSION}\n2.2" | sort -rV | head -n1) ] && echo 1)'
run-shell 'tmux setenv -g TMUX_GTE_2_4 $([ "${TMUX_VERSION}" = $(echo "${TMUX_VERSION}\n2.4" | sort -rV | head -n1) ] && echo 1)'
run-shell 'tmux setenv -g TMUX_GTE_2_7 $([ "${TMUX_VERSION}" = $(echo "${TMUX_VERSION}\n2.7" | sort -rV | head -n1) ] && echo 1)'
run-shell 'tmux setenv -g TMUX_GTE_2_9 $([ "${TMUX_VERSION}" = $(echo "${TMUX_VERSION}\n2.9" | sort -rV | head -n1) ] && echo 1)'
# ==================
# === Navigation ===
# ==================
# http://robots.thoughtbot.com/post/53022241323/seamlessly-navigate-vim-and-tmux-splits
# http://sourceforge.net/mailarchive/message.php?msg_id=30519263
# M(eta) is the Alt key both in Vim and tmux.
bind-key -n M-Left run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Left) || tmux select-pane -L; exit 0"
bind-key -n M-Down run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Down) || tmux select-pane -D; exit 0"
bind-key -n M-Up run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Up) || tmux select-pane -U; exit 0"
bind-key -n M-Right run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Right) || tmux select-pane -R; exit 0"
bind-key -n M-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Left) || tmux select-pane -L; exit 0"
bind-key -n M-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Down) || tmux select-pane -D; exit 0"
bind-key -n M-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Up) || tmux select-pane -U; exit 0"
bind-key -n M-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys M-Right) || tmux select-pane -R; exit 0"
# Enable mouse support.
if-shell '[ -n "${TMUX_GTE_2_1}" ]' \
"set-option -g mouse on" \
"set -g mode-mouse on; set -g mouse-resize-pane on; set -g mouse-select-pane on; set -g mouse-select-window on"
# ======================
# === Responsiveness ===
# ======================
# Decrease command delay (increases vim responsiveness)
set-option -sg escape-time 1
# If using normal keybindings this reduce the repeat time for key strokes when
# switching ppanes - the default is 500 ms.
set-option -g repeat-time 300
# =============
# === Shell ===
# =============
set-option -g default-shell $SHELL
# ==================
# === Status Bar ===
# ==================
set-option -g status-left " [#S] "
set-option -g status-interval 1 # refresh every second (useful for branch/path info)
set-option -g window-status-separator ''
set-option -wg window-status-activity-style 'none'
set-option -wg window-status-bell-style 'fg=colour3'
set-option -g status-right-length 140
# For the hostname on macOS, it changes depending on the network, so we try to
# use ComputerName if possible.
set-option -wg window-status-style "bg=colour0 fg=colour7"
set-option -wg window-status-current-style "bg=terminal fg=colour12"
set-option -g status-style "bg=colour0 fg=colour15"
set-option -wg window-status-format " #I:#W #[fg=colour7]β" # ββ
set-option -g status-right '#[fg=colour7]β #[fg=colour13]#{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,}#(if [[ "$OSTYPE" = darwin* && -n $(scutil --get ComputerName 2>/dev/null) ]]; then scutil --get ComputerName 2>/dev/null; else hostname | sed "s|\..*||"; fi) #[fg=colour7]β #[fg=colour4]#(echo "#{pane_current_path}" | sed "s|^$HOME|~|" | sed "s|/private/|/|") #[fg=colour10]#(cd #{pane_current_path}; branch=$(git branch --show-current 2>/dev/null); [[ -n "${branch}" ]] && echo "#[fg=colour7]β #[fg=colour2]β $(git branch --show-current) ")'
set-option -wg window-status-current-format " β― #I:#W #[fg=colour7]β"
set-option -g status-left " [#S]#[fg=colour7]β"
# ==============================
# === Terminal Compatibility ===
# ==============================
# tmux requires TERM to be either "screen[...]" or "tmux[...]".
#
# Setting it to tmux-256color will provide better compatibility for text
# rendering (including italics) and keycode reporting (for native key combos in
# many TUIs including Vim).
#
# You must compile the two files "tmux.terminfo" and "tmux-256color.terminfo"
# with "tic" for this to work.
set-option -g default-terminal "tmux-256color"
# Required for Neovim for termguicolors to work, as instructed by :checkhealth.
set-option -sa terminal-overrides ",xterm-256color:RGB"
# Vim knows that xterm-like terminals support extended sequences for certain
# modified keys (eg: CMD+Up), but this does not work when using screen TERMs.
# Setting xterm-keys on allows the use of xterm key bindings in tmux so that
# the keys can be passed down to vim in xterm format.
set-option -g xterm-keys on
# =========================
# === Vim Compatability ===
# =========================
# Allow vi-like movements when in copy mode, so that it is possible to
# copy-paste between panes and between the terminal and vim.
set-window-option -g mode-keys vi
# Make tmux copy mode feel more like vim.
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi r send -X rectangle-toggle
bind-key -T copy-mode-vi y send -X copy-selection-and-cancel
bind-key -T copy-mode-vi p send -X paste-buffer
# Prevent the window from jumping to the bottom when leaving copy mode.
if-shell '[ -n "${TMUX_GTE_2_4}" ]' \
"bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection" \
"bind-key -t vi-copy MouseDragEnd1Pane copy-selection -x"
{{ if eq .chezmoi.os "darwin" -}}
# Patch for OS X pbpaste and pbcopy under tmux.
set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL"
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
{{ else if lookPath "xclip" -}}
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
{{ end -}}
# =========================
# === Window Management ===
# =========================
# Number windows from 1, and ensure numbering is updated when windows are
# destroyed.
set-option -g base-index 1
set-option -g renumber-windows on
# Number panes from 1
set-window-option -g pane-base-index 1
# Constrain the size of the window to the size of the smallest client attached
# to the session.
set-window-option -g aggressive-resize on
set-window-option -g window-size smallest
# Highlight window when it has new activity.
set-window-option -g monitor-activity on
# Allow neovim to support autoread events
set-option -g focus-events on
# Override the new-window shortcut to create a new window in the same directory
# as the current pane, instead of the default one.
bind-key c new-window -c "#{pane_current_path}"
# Think about splits in terms of the orientation of the divider (they do not
# override the defaults). Each new pane will be created in the same directory
# as the current pane, instead of the default one.
bind-key | split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"
# After splitting the window vertically I almost never want a 50/50 split. This
# convenience binding will reduce the pane size.
bind-key _ resize-pane -D 15
# Shift is swallowed by gnome-terminal.
bind-key -n M-PageDown select-window -t :+
bind-key -n M-PageUp select-window -t :-
# Toggle to the previous active window.
bind-key ^b last-window
# Reorder windows.
bind-key j swap-window -t -1\; select-window -t -1
bind-key k swap-window -t +1\; select-window -t +1
# ===============
# === Plugins ===
# ===============
# enable tmux session persistance
set-option -g @plugin "tmux-plugins/tpm"
set-option -g @plugin "tmux-plugins/tmux-sensible"
set-option -g @plugin "tmux-plugins/tmux-resurrect"
set-option -g @plugin "tmux-plugins/tmux-continuum"
set-option -g @continuum-restore "off" # Explicity off becuase this behaviour is annoying.
set-option -g @resurrect-strategy-vim "session"
set-option -g @resurrect-strategy-nvim "session"
# enable tmux plugin manager
run-shell -b "~/.tmux/plugins/tpm/tpm"
if-shell "[ -f ~/.tmux.conf.after ]" "source ~/.tmux.conf.after"