/
_tmux.conf
238 lines (204 loc) · 5.98 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
# TMUX SESSION CHEAT SHEET
#
# SHOW SETTINGS - tmux list-keys
#
# `t - create tab
# `1 - move to tab 1
# `2 - move to tab 2
# `N - move to tab <N>
#
# `s - split horizontal (`S 25%)
# `v - split vertical (`V 25%)
#
# `j - move focus to upper pane
# `k - move focus to lower pane
# `h - move focus to left pane
# `l - move focus to right pane
#
# shift-UP - resize pane up
# shift-DOWN - resize pane down
# shift-LEFT - resize pane left
# shift-RIGHT - resize pane right
#
# `<space> - alter pane layout
# `o - rotate panes
# `! - turn pane into tab
# `@ - merge another pane into tab
# `% - send pane to another tab
# `, - rename tab
# `z - zoom pane
#
# `x - delete tab
# `d - detach from session
# `X - delete session
#
# TMUX COPY/PASTE CHEAT SHEET
#
# `[ - enter copy mode
#
# >>> in copy mode...
#
# g - top of buffer
# G - bottom of buffer
# / - search forward
# ? - search backward
# n - next search item
# <space>/v - start selection
# <enter>/y - yank selection and return to normal mode
#
# V - select line mode (j/k to select multiple lines)
#
# q - quit copy mode and return to normal mode
#
# >>> in normal mode...
#
# `p - paste from tmux buffer
#
# `C-c - save tmux buffer to X11 buffer
# `C-p - paste from X11 buffer
#
# `# - list all tmux buffers
# `- - delete the most recently copied buffer
# `= - choose which buffer to paste
#
# TMUX COMMAND LINE CHEAT SHEET
#
# > tmux ls # list tmux sessions
# > tmux attach <n> # attach to session [<N>]
#
# TMATE INSTRUCTIONS
#
# TMATE is a pair-programming tool that works across firewalls.
#
# https://tmate.io
# https://github.com/tmate-io/tmate
# https://github.com/tmate-io/tmate/releases
#
# Install TMATE from the releases page.
#
# The normal use is to run a vidoeconference and a terminal session
# side-by-side. Then you start tmate, then run `tmate show-messages` to get the
# ssh session-key. Send the ssh session key to your collaborator via chat.
#
# Protip for linux desktop users:
#
# sessionkey () {
# tmate show-messages | grep 'ssh session:' | cut -d ' ' -f10 | tee >(xclip -sel clipboard)
# }
#
# run `sessionkey`, then you can paste the session-key directly into chat...
#
# >>>>> BASE SETTINGS
# Focus-Events (wanted by Neovim)
set-option -g focus-events on
# Options keys
unbind C-b # disable default option key
set-option -g prefix C-a # use same option key as Screen
set-option -g prefix ` # backtick alternative
# send prefix to other applications (ie Vim)
# send ` or C-a to Vim by pressing it *twice*
bind ` send-prefix
bind C-a send-prefix
# unbind keys to eliminate vim conflict
unbind C-Up
unbind C-Down
unbind C-Left
unbind C-Right
# status line
set -g status-left-length 16
set -g status-right "#{=25:pane_title} | %Y %b %d %a | %H:%M"
# terminal settings
set-window-option -g xterm-keys on
set-window-option -g mode-keys vi
set-option -g status-keys vi
set-option -g status-position top
set-option -g default-terminal "screen-256color"
set-option -sa terminal-overrides ',xterm-256color:RGB'
set-option -ga terminal-overrides ',xterm-256color:Tc'
# mouse support
setw -g mouse on
# Toggle mouse on with `M
unbind M
bind M \
setw -g mouse on \;\
display 'Mouse: ON'
# Toggle mouse off with `m
unbind m
bind m \
setw -g mouse off \;\
display 'Mouse: OFF'
# >>>>> COPY/PASTE
# copy/paste within Tmux
unbind n
unbind p
# Redefine copy keys - works in TMUX but not TMATE
# > see the functions `live_tmux` and `live_tmate` in ~/.bashrc_util
# if-shell 'live_tmux' \
# " unbind -T copy-mode-vi v \
# unbind -T copy-mode-vi y \
# bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel \
# bind-key -T copy-mode-vi v send-keys -X begin-selection "
# unbind -T copy-mode-vi v
# unbind -T copy-mode-vi y
# bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# bind-key -T copy-mode-vi v send-keys -X begin-selection
bind p paste-buffer # in normal mode
# copy/paste between tmux and X11
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
# >>>>> WINDOW MANAGEMENT
# start window and pane numbering at '1'
set -g base-index 1
set -g pane-base-index 1
# kill windows and sessions
bind x kill-window # kill the active window
bind X kill-session # kill all windows
# Commands for creating split window panes
unbind % # disable default key
bind v split-window -h -c "#{pane_current_path}" # vertical split
bind s split-window -v -c "#{pane_current_path}" # horizontal split
bind V split-window -h -p 25
bind S split-window -v -p 25
bind T split-window -l 1 toma
# pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# tab navigation
bind Left previous-window
bind Right next-window
# pane resizing
bind -n S-Up resize-pane -U 2
bind -n S-Down resize-pane -D 2
bind -n S-Right resize-pane -R 2
bind -n S-Left resize-pane -L 2
# swap panes
unbind o
bind o rotate-window -D
# merge another window into current window
bind-key @ command-prompt -p "create pane from tab:" "join-pane -s ':%%'"
bind-key % command-prompt -p "send pane to tab:" "join-pane -t ':%%'"
# note: ! mapped to break-pane
# Do not notify upon activity in hidden windows
setw -g monitor-activity off
setw -g visual-activity off
# Swap New-Window and Clock Commands
unbind t
unbind c
bind c clock # clock!
bind t new-window -c "#{pane_current_path}" # new tab
# Renumber windows
unbind n
bind n move-window -r\; display "Renumbered tabs"
# Reload .tmux.conf
unbind r
bind r source-file ~/.tmux.conf\; display "Reloaded conf"
# xterm-title
set -g set-titles on
set -g set-titles-string '<#S:#I #W> #H'
set -g automatic-rename on
# Full color for Vim.
# Fix slow escape issue
# http://unix.stackexchange.com/questions/23138/esc-key-causes-a-small-delay-in-terminal-due-to-its-alt-behavior
set -sg escape-time 0