-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.conf
225 lines (173 loc) · 7.53 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
# C-q works for me, mostly
unbind C-q
set -g prefix C-q
set -g prefix2 C-a
unbind C-b
bind C-a send-prefix -2
bind m {
set -w monitor-bell
set -w monitor-activity
display 'window mute #{?#{monitor-bell},off,on}'
}
# Send C-a to apps (with C-a C-a)
#bind C-a send-prefix
# setting the dealy between prefix and command (+responsive)
set -s escape-time 0
set -sg repeat-time 600
# ??
set -s focus-events on
# start numbering windows and panes at 1
set -g base-index 1
set -g pane-base-index 1
# always renumber windows
set-option -g renumber-windows on
# Set bell/ring enabled
set-window-option -g visual-bell off
set-window-option -g bell-action any
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# splitting panes
bind | split-window -h
bind - split-window -v
bind s split-window -h
bind v split-window -v
# move between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Swap panes
bind > swap-pane -D
bind < swap-pane -U
# quick pane selection
bind-key -r C-h previous-window
bind-key -r [ previous-window
bind-key -r C-l next-window
bind-key -r ] next-window
bind Tab last-window # move to last active window
# pane resizing
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
# open new window in current directory
bind c new-window -c '#{pane_current_path}' -a -t '{next}'
bind -n M-c new-window -c '#{pane_current_path}' -a -t '{next}'
bind -n M-z resize-pane -Z
# CTRL-A, CTRL-E in copy mode
# bind -r C-a send-keys -X start-of-line
# bind -r C-e send-keys -X end-of-line
# mouse support
set -g mouse on
# copy to OS clipboard
set -g set-clipboard on
# Don't keep windows around after they exit
set -g remain-on-exit off
# clipboard sharing, isn't this the default now?
#bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "bash $HOME/bin/clip copy"
#bind-key -T copy-mode-vi p send-keys -X copy-pipe-and-cancel "bash $HOME/bin/clip paste
#
#bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "bash $HOME/clip copy"
#bind-key -n MouseDown3Pane run "bash $HOME/clip paste | tmux load-buffer - ; tmux paste-buffer"
# set the default terminal to 256color mode
# Other Options: "screen-256color" "xterm-256color" "screen-256color-bce" "xterm"
#set -g default-terminal "xterm-256color"
#set -ag terminal-overrides ",xterm-256color:RGB"
# enable activity monitor
setw -g monitor-activity on
set -g visual-activity on
set-window-option -g visual-bell on
set-window-option -g bell-action none
set -g set-titles on
set -g set-titles-string "#W"
set-option -g default-shell $SHELL
set -g history-limit 32768
# enable vi keys
setw -g mode-keys vi
#set -g mode-keys emacs
set -g status-keys emacs
# -- status bar --
set -g allow-rename on
set -g status 2
# set -g status 2 # for a two line status bar
set -g status-format[1] '#[align=centre]#{pane_title}'
# https://unix.stackexchange.com/questions/141311/tmux-hightlight-colour-setting
set -g mode-style "fg=colour81,bg=colour234"
# Set the status bar update interval
set -g status-interval 1
# Set the status bar position to bottom
set -g status-position top
# Define a gradient color scheme
# background and fg of status bar
# set -g status-bg colour234 # Base background color
# set -g status-fg colour255 # Base foreground color
set -g status-style 'bg=#44475a,fg=#f8f8f2'
set -g message-style "bg=colour81,fg=colour234,bold"
# Left side of the status bar (session information)
set -g status-left-length 40
set -g status-left "#[fg=colour81,bg=colour234,bold]#S #[fg=colour255,bg=colour234,nobold]"
# Right side of the status bar (date, time, and hostname)
set -g status-right-length 40
set -g status-right "#[fg=colour255,bg=colour234,nobold]#[fg=colour234,bg=colour81,bold] %Y-%m-%d %H:%M #[fg=colour81,bg=colour234,bold]#[fg=colour234,bg=colour81,bold]"
# Window list style
set -g window-status-format "#[fg=colour244,bg=colour234] #I #W #F"
set -g window-status-current-format "#[fg=colour234,bg=colour81,bold] #I #W #[fg=colour81,bg=colour234,nobold]"
# Pane border style
setw -g pane-active-border-style "bg=colour0,fg=colour81"
setw -g pane-border-style "bg=colour0,fg=colour234"
# -- copy mode -----------------------------------------------------------------
unbind Escape
bind Enter copy-mode # enter copy mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi H send -X start-of-line
bind -T copy-mode-vi L send -X end-of-line
# Search forward in copy-mode
bind -T copy-mode-vi / send -X search-forward
bind -T copy-mode-vi ? send search-backward
# page-up and page-down
bind -r PPage copy-mode -u
# XXX: fix this
# bind -r NPage copy-mode -d
bind -r NPage send -X page-down
# mod-up and mod-down
bind -r M-Up copy-mode -u
bind -r M-Down send -X page-down
# bind -r M-Down copy-mode -d
# copy to X11 clipboard
if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | xsel -i -b"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"'
# copy to Wayland clipboard
if -b '[ "$XDG_SESSION_TYPE" = "wayland" ] && command -v wl-copy > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | wl-copy"'
# copy to macOS clipboard
if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | pbcopy"'
# copy to Windows clipboard
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | clip.exe"'
if -b '[ -c /dev/clipboard ]' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - > /dev/clipboard"'
# -- buffers -------------------------------------------------------------------
bind b list-buffers # list paste buffers
bind p paste-buffer -p # paste from the top paste buffer
bind P choose-buffer # choose which buffer to paste from
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind C-p display-menu -T "#[align=centre fg=yellow]Commands Menu" \
"Synchronize Panes ON (s)" s 'setw synchronize-panes on' \
"Synchronize Panes OFF (x)" x 'setw synchronize-panes off' \
"List buffers (l)" l 'send-keys "your-command-here" C-m'