/
.tmux.conf
219 lines (172 loc) · 6.32 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
# tmux configuration file
#set -g default-terminal "xterm-16color"
#set -g default-terminal "xterm-256color"
set -g default-terminal "screen-256color"
set -g default-shell $SHELL
set -g default-command "reattach-to-user-namespace -l ${SHELL}"
set -g allow-passthrough 1
# change prefix to C-a
set -g prefix C-a
# set -g prefix2 ^" "
# use C-a C-a to send prefix to an inner tmux session
bind C-a send-prefix
bind % split-window -h -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# open a new window in my home directory
bind v new-window -c "~"
# open a new window with a "horizontal" split
bind b new-window \; split-window -h
bind n next-window
unbind C-n
bind -r C-n next-window
unbind m
bind -r m previous-window
# move original , binding to < and use , for last-window
unbind <
bind < command-prompt "rename-window '%%'"
unbind ,
bind , last-window
unbind '$'
bind '$' command-prompt "rename-session '%%'"
# unbind r
# bind r refresh-client \; display-message "..."
# reload config file
unbind r
bind r source-file ~/.tmux.conf \; display-message "Config reloaded."
# clear pane history buffer
unbind R
bind R clear-history \; display-message "History cleared."
# vim style pane navigation
# use C+[hjkl] to move more than one pane in succession
unbind j
bind j select-pane -D
unbind C-j
bind -r C-j select-pane -D
unbind k
bind k select-pane -U
unbind C-k
bind -r C-k select-pane -U
unbind h
bind h select-pane -L
unbind C-h
bind -r C-h select-pane -L
unbind l
bind l select-pane -R
unbind C-l
bind -r C-l select-pane -R
# smart pane switching with awareness of vim splits
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# replace clear screen (C-l)
unbind -n 'C-\'
# bind -n C-\ send-keys 'C-l'
bind 'C-\' send-keys 'C-l'
bind Enter send-keys ''
# move panes
bind C-f command-prompt -p "join pane from:" "join-pane -s '%%'"
bind C-t command-prompt -p "send pane to:" "join-pane -t '%%'"
bind S display-panes \;\
command-prompt -p "swap pane from:, swap pane to:" "swap-pane -s '%%' -t '%%'"
# move windows
unbind M
bind -r M swap-window -t -1
unbind N
bind -r N swap-window -t +1
# vim style copy-paste
set -g mode-keys vi
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -T copy-mode-vi 'v' send -X begin-selection
# handled by tmux-plugins/yank
#bind -t vi-copy 'y' copy-selection
#bind -t vi-copy 'y' copy-pipe 'xclip -selection clipboard'
# copy/paste
# C-c: save into system clipboard (+). With preselection.
bind C-c choose-buffer "run \"tmux save-buffer -b %% - | xclip -i -sel clipboard\" \; run \" tmux display \\\"Clipboard \(+\) filled with: $(tmux save-buffer -b %1 - | dd ibs=1 obs=1 status=noxfer count=80 2> /dev/null)... \\\" \" "
# C-v: copy from + clipboard.
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer" \; run "tmux display \"Copied from \(+\) $(xclip -o -sel clipboard | dd ibs=1 obs=1 status=noxfer count=80 2> /dev/null)... \""
# make tmux command prompt nicer
set -g status-keys emacs # because I want escape to exit the command prompt
unbind \;
bind \; command-prompt -p ">"
# make choice mode nicer
# bind -t vi-choice Escape cancel
# bottom in a new window (https://github.com/ClementTsang/bottom)
bin '`' new-window btm
# htop in a new split
bind '\' split-window -v -p 50 "htop"
# don't wait for an escape sequence (for vim)
set -sg escape-time 0
# wait one second for repeat commands
set -g repeat-time 1000
# generate xterm-style function key sequences
# (makes function + arrow keys work correctly)
set -g xterm-keys on
# fix printing garbage characters to the screen after mouse selection
set -g set-clipboard off
# leave output of applications (like less) on the screen after exiting
# set-window-option -g alternate-screen off
# enable all mouse functionality (new in tmux 2.1)
set -g mouse on
set -g history-limit 32000
set -g message-limit 100
set -g aggressive-resize on
# Appearance
set -g base-index 1
set -g renumber-windows on
set -g pane-base-index 1
set -g set-titles on
set -g set-titles-string "#h - #S - #W"
set -g automatic-rename on
# set -g monitor-activity on
# set -g activity-action any
# set -g monitor-bell on
# set -g visual-bell on
# set -g visual-activity on
set -g display-time 1500
set -g display-panes-time 1500
set -g message-command-style bg=colour243,fg=black # doesn't really work
set -g message-style bg=colour243,fg=black
set -g pane-active-border-style bg=default,fg=green
# Statusline
set -g status-bg colour237
set -g window-status-current-style bg=green # active window
set -g window-status-activity-style bg=default,fg=yellow
set -g window-status-bell-style bg=black,fg=red
set -g window-status-last-style fg=green
set -g window-status-separator ' | '
set -g status-right-length 80
set -g status-right "#{?client_prefix,#[fg=red][P]#[fg=default],} [#(kubectl config current-context)][#h]"
# Environment
# See https://github.com/agriffis/weechat-tmux-env
set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY DBUS_SESSION_BUS_ADDRESS'
### Plugins
# tpm plugins (fetch with prefix + I)
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @yank_action 'copy-pipe' # or 'copy-pipe-and-cancel' for the default
# save: prefix + ctrl-s
# restore: prefix + ctrl-r
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/vim-tmux-focus-events'
set -g @plugin 'tmux-plugins/tmux-copycat'
# sidebar with directory tree: prefix+tab
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @sidebar-tree-command 'tree -C' # colors
set -g @plugin 'nhdaly/tmux-scroll-copy-mode'
set -g @scroll-without-changing-pane 'on'
set -g @scroll-speed-num-lines-per-scroll 2
set -g @emulate-scroll-for-no-mouse-alternate-buffer 'on'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @save-complete-history-key 'H'
set -g @plugin 'pawel-wiejacha/tmux-picker'
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'