-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf
205 lines (166 loc) · 6.86 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
###########################
# TMUX Configuration
# migrated to tmux 2.9 August 10, 2019
# minimum version supported is tmux 2.6
###########################
# get tmux version without decimal points: 1.8 becomes 18, 2.1 becomes 21, etc.
# this way we can test the version with pure shell, not needing bc(1) for floating point test
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | tr -dc '[0-9]')"
run-shell "tmux setenv -g STATUS_MEM_CMD 'set $(free -ht|tail -1) && echo $3 of $2'"
# use 256 term for pretty colors
set -g default-terminal "screen-256color"
# allow terminals to set the title
set -ga terminal-overrides ',xterm*:XT:smcup@:rmcup@,rxvt*:XT,urxvt*:XT'
set -g set-titles on
set -g set-titles-string "#T"
# use bash
# setting default-shell causes tmux to start a login shell, which is arguably wrong
# setting default-command causes tmux to start a non-login, interactive shell
set -g default-shell "/bin/bash"
#set -g default-shell "/usr/bin/fish"
#set -g default-command "/usr/bin/fish"
#set -g default-command "/opt/homebrew/bin/bash"
# OSX ONLY # enable pbcopy and pbpaste
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/README.md
# set -g default-command "reattach-to-user-namespace -l bash"
# increase scroll-back history
set -g history-limit 10000
# use emacs key bindings
setw -g mode-keys emacs
set -g status-keys emacs
# enable mouse copy/paste
set -g mouse on
# decrease command delay (increases vim responsiveness)
set -sg escape-time 1
# increase repeat time for repeatable commands
set -g repeat-time 1000
# increase the status line display time
set -g display-time 1000
# start window and pane indices at 1
set -g base-index 1
setw -g pane-base-index 1
# highlight window when it has new activity
setw -g monitor-activity on
set -g visual-activity on
# re-number windows when one is closed.
# set -g renumber-windows on
# OSX ONLY # enable pbcopy and pbpaste
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/README.md
# set -g default-command "reattach-to-user-namespace -l bash"
#################################################################################
# Key Bindings
#################################################################################
# tmux prefix set to backtick. This is rarely used for anything else, and it's less fingers than CTRL-A
# also, `1 `2 `3 chooses windows really quickly.
unbind C-b
set -g prefix `
bind ` send-prefix
# command prompt on both colon and semi-colon, makes it reachable without SHIFT key
bind : command-prompt
bind \; command-prompt
# swap the PREFIX key around.
# sometimes you need the backtick, so use f11 and f12 to quickly change from one to the other.
# f11 bound to set prefix to backtick
# f12 bound to set prefix to CTRL-A
bind -n F11 set -g prefix ` \; bind ` send-prefix
bind -n F12 set -g prefix C-a \; bind C-a send-prefix
# To copy:
if-shell -b 'test $TMUX_VERSION -lt 24' \
'bind -t emacs-copy M-w copy-pipe "xclip -i -sel p -f | xclip -i -sel c" \; display-message "copied to system clipboard"' \
'bind -T copy-mode M-w send -X copy-pipe "xclip -i -sel p -f | xclip -i -sel c" \; display-message "copied to system clipboard"'
# To paste:
unbind C-y
bind -n C-y run "xclip -o | tmux load-buffer - ; tmux paste-buffer"
unbind C-v
bind -n C-v run "tmux save-buffer - | xclip -i -sel p -f | xclip -i -sel c -f | tmux load-buffer - ; tmux paste-buffer"
# window splitting
unbind %
unbind '"'
bind | split-window -h -c "#{pane_current_path}"
bind '\' split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
if-shell -b 'test $TMUX_VERSION -le 28' \
'bind "\\" split-window -h' \
'bind "\\" split-window -h -c "#{pane_current_path}"'
# vi hjkl pane travel
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# resize panes
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# quickly switch panes
unbind C-j
bind / last-pane
bind < select-pane -t :.-
bind > select-pane -t :.+
bind , select-pane -t :.- # <
bind . select-pane -t :.+ # >
# toggle synchronize typing in panes
bind y setw synchronize-panes
# bind some window control keys
bind = new-window
bind + new-window
bind x kill-pane
bind X kill-window
bind n command-prompt 'rename-window %%'
bind N command-prompt 'rename-session %%'
# man pages
unbind m
bind m command-prompt "split-window 'man %%'"
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display ".tmux.conf Reloaded!"
###########################
# Status Bar
###########################
# enable UTF-8 support in status bar for versions less than 2.2.
if-shell -b 'test $TMUX_VERSION -lt 22' '\
set -g utf8 on ;\
set -g status-utf8 on ;\
set -g mouse-utf8 on'
# set refresh interval for status bar
set -g status-interval 30
# center the status bar
set -g status-justify left
# show session name in green, then window:pane in left status bar
set -g status-left-length 40
set -g status-left '#[fg=green]#S#[fg=yellow] #I:#P#[default] '
# show hostname, load, date, time in the right bar
set -g status-right-length 1000
# 'set -g status-right "#[default]| #[fg=green]#h#[default] | #[fg=red,bright]used: #(~/bin/tmux-mem.sh)#[default] | #[fg=yellow,bright]load: #(cut -f1 -d\" \" /proc/loadavg)#[default] | %A %Y-%m-%d %H:%M "'
if-shell -b '[ -x ~/bin/tmux-mem.sh ]' \
'set -g status-right "#[default]| #[fg=green]#h#[default] | #[fg=red,bright]used: #($STATUS_MEM_CMD)#[default] | #[fg=yellow,bright]load: #(cut -f1 -d\" \" /proc/loadavg)#[default] | %A %Y-%m-%d %H:%M "' \
'set display-time 5000 ;\
display "install ~/bin/tmux-mem.sh to see memory free" ;\
set -u display-time ;\
set -g status-right "#[default]| #[fg=green]#h#[default] | #[fg=yellow,bright]load: #(cut -f1 -d\" \" /proc/loadavg)#[default] | %A %Y-%m-%d %H:%M "'
###########################
# Colors
###########################
if-shell -b 'test $TMUX_VERSION -le 28' \
" \
set -g status-bg colour235 ;\
set -g status-fg yellow ;\
set -g status-attr dim ;\
set-window-option -g window-status-fg brightblue ;\
set-window-option -g window-status-bg colour236 ;\
set-window-option -g window-status-attr dim ;\
set-window-option -g window-status-current-fg brightred ;\
set-window-option -g window-status-current-bg colour236 ;\
set-window-option -g window-status-current-attr bright ;\
set -g pane-border-fg blue ;\
set -g pane-border-bg black ;\
set -g pane-active-border-fg green ;\
set -g pane-active-border-bg black ;\
"
if-shell -b 'test $TMUX_VERSION -ge 29' \
" \
set -g status-style bg=colour235,fg=yellow,dim ;\
set -g window-status-style bg=colour236,fg=brightblue,dim ;\
set -g window-status-current-style bg=colour236,fg=brightred,bright ;\
set -g window-status-current-style bg=colour236,fg=brightred,bright ;\
"