/
.tmux.conf
236 lines (174 loc) · 8.23 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
################################################################################
# Dev Loop
################################################################################
# Re-source tmux. Useful while working in this file
bind-key R source-file ~/.tmux.conf \; \
display-message "source-file done"
# more history
set-option -g history-limit 20000
################################################################################
# Tmux Plugins
################################################################################
set -g @plugin 'dalejung/tmux-select-pane-no-wrap'
set -g @plugin 'jonmosco/kube-tmux'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @copycat_next 'p'
set -g @copycat_prev 'n'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-urlview'
set -g @plugin 'tmux-plugins/tmux-yank'
################################################################################
# Context Helpers
################################################################################
# Convenience defn for creating vim-specific kbd behavior
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_vim_or_emacs="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?|emacsc?l?i?e?n?t?)(diff)?$'"
################################################################################
# Tmux Leader
################################################################################
# change tmux leader
unbind C-b
set -g prefix C-q
bind C-q send-prefix
################################################################################
# Colors
################################################################################
# COLORS!
set -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
################################################################################
# Copy Paste
################################################################################
# copy text like it's Vim
# bind -n Escape if-shell "${is_vim_or_emacs}" "send-keys Escape" copy-mode
bind -n C-z copy-mode
bind -n C-u copy-mode
# # Use vim keybindings in copy mode
setw -g mode-keys vi
# # Setup 'v' to begin selection as in Vim
bind -Tcopy-mode-vi v send -X begin-selection
bind -Tcopy-mode-vi y send -X copy-pipe-and-cancel "xclip"
bind -Tcopy-mode-vi Escape send -X cancel
bind -Tcopy-mode-vi V send -X rectangle-toggle
# # Update default binding of `Enter` to also use copy-pipe
unbind -Tcopy-mode Enter
bind -Tcopy-mode Enter send -X copy-pipe-and-cancel "xclip"
################################################################################
# Windows
################################################################################
# Transpose window layouts
bind-key -n M-r rotate-window -D
bind-key -n M-R next-layout
# start window indicies at 1
set -g base-index 1
# window naming nonsense
set-window-option -g automatic-rename on
set-window-option -g allow-rename off
# Easier window swaps
bind -n C-left swap-window -t -1
bind -n C-right swap-window -t +1
# Easier window moves
bind -n m-left previous-window
bind -n m-right next-window
# Option/Meta + number to jump to window
bind -n m-0 select-window -t 0
bind -n m-1 select-window -t 1
bind -n m-2 select-window -t 2
bind -n m-3 select-window -t 3
bind -n m-4 select-window -t 4
bind -n m-5 select-window -t 5
bind -n m-6 select-window -t 6
bind -n m-7 select-window -t 7
bind -n m-8 select-window -t 8
bind -n m-9 select-window -t 9
# split window shortcuts, maintaing the working directory
bind-key -n M-\\ split-window -h -c '#{pane_current_path}'
bind-key -n M-- split-window -v -c '#{pane_current_path}'
bind-key -n M-_ split-window -v -c '#{pane_current_path}'
# new window
bind-key -n M-c new-window -c "#{pane_current_path}"
# maintain working directory for default tmux splits/new window
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
################################################################################
# Panes
################################################################################
# Maximize current pane
bind-key -n M-z resize-pane -Z
# Pane resizing
# TODO write tmux/vim aware resizing bindings (rewrite tmux navigate)
bind -n M-H resize-pane -L 5
bind -n M-J resize-pane -D 5
bind -n M-K resize-pane -U 5
bind -n M-L resize-pane -R 5
# Delete pane (without confirmation)
bind-key -n M-q if-shell "${is_vim_or_emacs}" "send-keys M-q" kill-pane
# Pane movement: Bindings from "christoomey/vim-tmux-navigator"
bind -n C-h if-shell "${is_vim_or_emacs}" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "${is_vim_or_emacs}" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "${is_vim_or_emacs}" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "${is_vim_or_emacs}" "send-keys C-l" "select-pane -R"
# bind -n M-h if-shell "${is_vim_or_emacs}" "send-keys M-h" "select-pane -L"
# bind -n M-j if-shell "${is_vim_or_emacs}" "send-keys M-j" "select-pane -D"
# bind -n M-k if-shell "${is_vim_or_emacs}" "send-keys M-k" "select-pane -U"
# bind -n M-l if-shell "${is_vim_or_emacs}" "send-keys M-l" "select-pane -R"
# bind -n M-h if-shell "${at_edge} L" "run-shell 'chunkc tiling::window --focus west'" "select-pane -L"
# bind -n M-j if-shell "${at_edge} D" "run-shell 'chunkc tiling::window --focus north'" "select-pane -D"
# bind -n M-k if-shell "${at_edge} U" "run-shell 'chunkc tiling::window --focus south'" "select-pane -U"
# bind -n M-l if-shell "${at_edge} R" "run-shell 'chunkc tiling::window --focus east'" "select-pane -R"
################################################################################
# Sessions
################################################################################
# Traverse sessions by index
bind -n m-p switch-client -p
bind -n m-n switch-client -n
# Select from current sessions
bind -n m-s choose-session
#################################################################################
## Powerline
#################################################################################
## powerline for tmux
run-shell "powerline-daemon -q"
# source "/usr/lib/python3.7/site-packages/powerline/bindings/tmux/powerline.conf"
# setup powerline
if-shell 'env "$POWERLINE_CONFIG_COMMAND" tmux setup' '' 'run-shell "powerline-config tmux setup"'
# bind-key h set -g status
# set-option -g status on
# set-option -g status-interval 2
# set-option -g status-utf8 on
# set-option -g status-justify "centre"
# set-option -g status-left-length 60
# set-option -g status-right-length 90
# set-option -g status-left "#(~/dotfiles/tmux-powerline/powerline.sh left)"
# set-option -g status-right "#(~/dotfiles/tmux-powerline/powerline.sh right)"
################################################################################
# Misc
################################################################################
# fix for slow ESC issues
set -s escape-time 0
# Make tmux work like vi
set-window-option -g mode-keys vi
# Configuration for a Pomodoro timer available at 'tj/pomo'
# set-option -g status-right '#(cat ~/.pomo_stat)'
# set -g status-right "#(/bin/bash $HOME/.tmux/plugins/kube-tmux/kube.tmux 250 red cyan)"
# Click to select and resize panse.
# NOTE: you must now hold option to select text with the mouse!
set -g mouse on
#################################################################################
## Tmux Plugin Manager (TPM)
#################################################################################
# ensures tpm is present and plugins are installed
# recommended here: https://github.com/tmux-plugins/tpm/blob/c5c997bdde5d6a46d4b852e0a8164a30ca1dd0a4/docs/automatic_tpm_installation.md
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
# bootstrap plugins
run '~/.tmux/plugins/tpm/tpm'
# run install script
# TPM tells you to do this by hand via prefix + I, which is nonsense.
# This way starting up tmux installs missing plugins.
# For some reason this still fails to start all of them, prefix + I within tmux fixes it for now.
run '~/.tmux/plugins/tpm/scripts/install_plugins.sh'