-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
302 lines (228 loc) · 10.5 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# .tmux.conf of Lucas "LucEast" Ostmann, based on others (see below)
# last modified: 16 December 2020
# Using tmux 3.1c
#
## This tmux.conf is based on:
#check out this page for a tmux conf (basis for this one):
#http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
#
#thanks to dothebarbwa
#https://www.reddit.com/r/unixporn/comments/3cn5gi/tmux_is_my_wm_on_os_x/
#with my own modifications
#
#Remember: prefix-? shows all keybindings
#Priority: prefix key and reloading tmux.conf:
#-------------------------------------------------------#
#change prefix from C-b to C-a
unbind C-b
set -g prefix C-a
#bind C-a C-a to 'home', or start of line, which was C-a previously
bind C-a send-prefix
#reload tmux.conf message
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
#-------------------------------------------------------#
#Create R development environment with multiple windows
#-------------------------------------------------------#
#start off by renaming current window to R, then split, etc
bind F4 \
select-window -t :=1 \;\
rename-window 'R' \;\
split-window -h -c '#{pane_current_path}' \;\
new-window -c '#{pane_current_path}' \;\
rename-window 'scripts' \;\
new-window -c '#{pane_current_path}' \;\
rename-window 'git' \;\
new-window -c '#{pane_current_path}' \;\
rename-window 'tests' \;\
select-window -t :=1 \;\
display "R development environment created"
#-------------------------------------------------------#
#Pane navigation non-standard because of resizing pane prefix-L
#-------------------------------------------------------#
bind -r b previous-window
bind -r n next-window
bind -r p last-window
#-------------------------------------------------------#
#Terminal admin:
#-------------------------------------------------------#
#set mouse off/on - if off, forces you to use keyboard with prefix-[
#set -g mouse off
set -g mouse on
#256 colours
set -g default-terminal "screen-256color"
# start with window 1 (instead of 0)
set -g base-index 1
# start with pane 1
set -g pane-base-index 1
# use vi mode - not sure what these do...
setw -g mode-keys vi
set -g status-keys vi
#setw -g utf8 on
#set -g status-utf8 on
#-------------------------------------------------------#
#PANE COLOURS
#-------------------------------------------------------#
# set inactive/active window styles
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'
#pane border
#set -g pane-border-bg colour235
#set -g pane-border-fg colour238
#set -g pane-active-border-bg colour236
#set -g pane-active-border-fg colour51
#set -g pane-border-style fg=colour6
#-------------------------------------------------------#
#-------------------------------------------------------#
#PANE NAVIGATION/MANAGEMENT
#-------------------------------------------------------#
# splitting panes
#bind \ split-window -h
#bind - split-window -v
bind _ split-window -h -c '#{pane_current_path}'
bind - split-window -v -c '#{pane_current_path}'
# open new panes in current path
bind c new-window -c '#{pane_current_path}'
# Use Alt-arrow keys WITHOUT PREFIX KEY to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
#Resizing panes:
bind -r j resize-pane -D 2
bind -r k resize-pane -U 2
bind -r h resize-pane -L 2
bind -r l resize-pane -R 2
#Pane Movement
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
#-------------------------------------------------------#
#-------------------------------------------------------#
#Pane copy/pasting
#http://jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/
#-------------------------------------------------------#
#unbind [
#bind Escape copy-mode
bind C-v paste-buffer
#bind-key -t vi-copy 'v' begin-selection
#bind-key -t vi-copy 'y' copy-selection
#-------------------------------------------------------#
#-------------------------------------------------------#
#Setting escape time delay to be smaller
#to make tmux more responsive to commands
#-------------------------------------------------------#
set -s escape-time 1
#-------------------------------------------------------#
#-------------------------------------------------------#
##STATUS LINE/MESSAGES AT BOTTOM
#-------------------------------------------------------#
# Set background of status line to black
#-------------------------------------------------------#
#set -g status-bg blue
set -g status-bg black
#Colours for messages
#-------------------------------------------------------#
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
#Show reloaded message in bright white
#set -g message-fg white
#set -g message-bg default
#set -g message-attr bright
#-------------------------------------------------------#
# Status line left side
#-------------------------------------------------------#
# Session: 0 1 1 settings
set -g status-left-length 40
set -g status-left "#[fg=colour245] #S #[fg=colour84]#I #[fg=colour75]#P"
#-------------------------------------------------------#
#Window/pane type in centre
#-------------------------------------------------------#
#move bash* to centre
set -g status-justify centre
# set the color of the window list
# The name of the pane
#setw -g window-status-fg colour75
#setw -g window-status-bg default
#setw -g window-status-attr dim
#-------------------------------------------------------#
#Time and date on right-hand side
#-------------------------------------------------------#
# Status line right side
# 15% | 28 Nov 18:15
# e.g. 28 Nov 18:15
set -g status-right "#[fg=colour245]%d %b #[fg=colour256] %R"
# Update the status bar every sixty seconds
# For the time
set -g status-interval 60
#-------------------------------------------------------#
#-------------------------------------------------------#
#End of status line messages
#-------------------------------------------------------#
#-------------------------------------------------------#
#tmux resurrect
#https://github.com/tmux-plugins/tmux-resurrect
# tmux resurrect keys:
# prefix + Ctrl-s - save
# prefix + Ctrl-r - restore
# tmux resurrect folder:
# ~/.tmux/resurrect
#-------------------------------------------------------#
#activate tmux-resurrect
run-shell ~/build/tmux/tmux-resurrect/resurrect.tmux
#resurrect pane contents
#https://github.com/tmux-plugins/tmux-resurrect/blob/master/docs/restoring_pane_contents.md
set -g @resurrect-capture-pane-contents 'on'
#change defaults for resurrect (two steps)
#1. unbind the current defaults C-s and C-r
unbind-key -T prefix C-s
unbind-key -T prefix C-r
#2. Still use prefix C-s and C-r, but now ask for (y/n) response before saving/restoring.
#This assumes tmux-resurrect is saved to ~/build/tmux-resurrect folder
bind-key -T prefix C-s confirm-before -p 'Save this tmux session? (y/n)' 'run-shell ~/build/tmux/tmux-resurrect/scripts/save.sh'
bind-key -T prefix C-r confirm-before -p 'Resurrect last tmux session? (y/n)' 'run-shell ~/build/tmux/tmux-resurrect/scripts/restore.sh'
#-------------------------------------------------------#
#end of tmux resurrect
#-------------------------------------------------------#
#-------------------------------------------------------#
#reattach-to-user-namespace must be installed
#
#For opening Skim (and perhaps for copy/pasting)
#http://www.economyofeffort.com/2013/07/29/reattach-to-user-namespace-the-fix-for-your-tmux-in-os-x-woes/
#also have:
#set-option -g default-command "reattach-to-user-namespace -l ${SHELL}"
#in ~/.tmux-osx.conf
#-------------------------------------------------------#
if-shell 'test "$(uname)" = "Darwin"' 'source ~/.tmux-osx.conf'
#-------------------------------------------------------#
#=========================================================
#LaTeX Additions
#=========================================================
# F9 in tmux latex will
# 1) save the tex file
# 2) split window
# 3) clear screen
# 4) search for the most recently modified tex file and
# save in variable $thistexfile
# 5, 6, 7) save name for swp file
# 8) rm swp file (to avoid errors when latex compile finds an error
# 9) compile and exit IF SUCCESSFUL
# otherwise type 'x'
#for pdflatex use F6
#if no swap file in vim, using the following line in vimrc:
# set noswapfile
# then this will work
bind-key -n F6 send-keys Escape :w C-m \; split-window -v -p 20 -c '#{pane_current_path}' \; send-keys clear C-m\; send-keys 'thistexfile=$(ls -1t *.tex | head -1)' C-m \; send-keys 'pdflatex $thistexfile && exit' C-m
#if there are swap files, then use this:
#bind-key -n F6 send-keys Escape :w C-m \; split-window -v -p 20 -c '#{pane_current_path}'\; send-keys clear C-m\; send-keys 'thistexfile=$(ls -1t *.tex | head -1)' C-m \; send-keys 'swppre=.' C-m \; send-keys 'swpext=.swp' C-m \; send-keys 'swpfile=$swppre$thistexfile$swpext' C-m \; send-keys 'rm $swpfile' C-m \; send-keys 'pdflatex $thistexfile && exit' C-m
#for xelatex use F5
bind-key -n F5 send-keys Escape :w C-m \; split-window -v -p 20 -c '#{pane_current_path}' \; send-keys clear C-m\; send-keys 'thistexfile=$(ls -1t *.tex | head -1)' C-m \; send-keys 'xelatex $thistexfile && exit' C-m
#for masterfile use F7,
#if main file is main.tex, then there create an (empty) file: main.text.latexmaster
#if no .latexmaster file, then nothing happens
bind-key -n F7 send-keys Escape :w C-m \; split-window -v -p 20 -c '#{pane_current_path}' \; send-keys 'thistexfile=$(ls -1t *.tex | head -1)' C-m \; send-keys 'mastertexfile=$(ls -1t *.latexmaster | head -1)' C-m \; send-keys 'echo $mastertexfile' C-m \; send-keys clear C-m \; send-keys 'texfiletocompile=`echo $mastertexfile | sed -E ' \; send-keys "'s/(.*).latexmaster(.*)/\\1/'`" C-m \; send-keys 'if [ -z "$texfiletocompile" ] ; then exit ; else pdflatex $texfiletocompile && exit; fi' C-m
#extra C-m does not help
#; send-keys C-m
#for bibtex use F8
bind-key -n F8 send-keys Escape :w C-m \; split-window -v -p 20 -c '#{pane_current_path}' \; send-keys 'thistexfile=$(ls -1t *.tex | head -1)' C-m \; send-keys clear C-m \; send-keys 'thisfilebase=`echo $thistexfile | sed -E ' \; send-keys "'s/(.*).tex(.*)/\\1/'`" C-m \; send-keys 'echo $thisfilebase' C-m \; send-keys 'auxext=.aux' C-m \; send-keys 'thisauxfile=$thisfilebase$auxext' C-m \; send-keys 'echo $thisauxfile' C-m \; send-keys 'bibtex $thisauxfile && exit || printf "\nError while compiling $thisauxfile ; perhaps no .bib file/references for $thistexfile \n\n"' C-m
### End of tmux.conf
### Version 1 December 2020