-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtmux.conf
202 lines (164 loc) · 7.04 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
# tmux config
## options
### improve colors, enable italics with custom terminfo
### see: ~/.config/tmux-256color.terminfo
set -g default-terminal tmux-256color
# set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'
### start numbering windows at 1 (to match up with ^a<n>)
set -g base-index 1
### vim mode
setw -g mode-keys vi
set -g status-keys vi
### automatic window renaming
setw -g allow-rename on
set -g set-titles on
setw -g automatic-rename on
set -g automatic-rename-format "#{?#{==:#{pane_current_command},zsh},#{s|#(whoami)|~|:#(basename #{pane_current_path})},#{pane_current_command}}"
# format ref: https://github.com/tmux/tmux/wiki/Formats#comparisons
# ^a+, for manual window rename
# ^a+$ for manual session rename
### fix vim focus events
# see: https://vi.stackexchange.com/a/13092
set -g focus-events on
### reduce latency switching modes in vim
set -s escape-time 0
### increase scrollback buffer
set -g history-limit 50000
# 'clear-history' to delete scrollback buffer
## bindings
### prefix (key to press before every other binding)
set -g prefix C-a # ^a
### movement between panes
bind h select-pane -L # ^a h
bind j select-pane -D # ^a j
bind k select-pane -U # ^a k
bind l select-pane -R # ^a l
### smart pane switching with awareness of vim splits
# see: https://github.com/christoomey/vim-tmux-navigator
# see: https://thoughtbot.com/blog/seamlessly-navigate-vim-and-tmux-splits
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" # ^h
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" # ^j
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" # ^k
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" # ^l
### movement between windows
bind C-a last-window # ^a ^a
bind -n M-l next-window # alt-l
bind -n M-h previous-window # alt-h
### movment between sessions
bind -n M-Tab switch-client -n # alt-tab
bind -n M-BTab switch-client -p # alt-shift-tab
### show session name after tab switching
if-shell "tmux set-hook client-session-changed 'display-message -d 500 \" #S\"'" "" ""
# disable any messages after changing i3 windows
if-shell "tmux set-hook -u pane-focus-in" "" ""
if-shell "tmux set-hook -u client-focus-in" "" ""
# wrapped in if-shell to hide errors on server startup
### kill window/pane
bind q confirm-before -p "Kill window #W? (y/n)" kill-window # ^a k
bind x confirm-before -p "Kill pane #P? (y/n)" kill-pane # ^a x
### swap/move windows
bind s command-prompt -p "Swap window with:" "swap-window -t ':%%'" # ^a s
bind m command-prompt -p "Move window to:" "move-window -t ':%%'" # ^a m
### split pane
bind i split-window -h -c '#{pane_current_path}' # ^a i
bind - split-window -v -c '#{pane_current_path}' # ^a -
bind I split-window -fh -c "#{pane_current_path}" # ^a I
bind _ split-window -fv -c "#{pane_current_path}" # ^a _
bind -n M-i split-window -h -l 30% -c '#{pane_current_path}' # ^a alti
bind -n M-- split-window -v -l 20% -c '#{pane_current_path}' # ^a alt-
bind M-1 split-window -v -p 10 -c '#{pane_current_path}' # ^a alt1
bind M-2 split-window -v -p 20 -c '#{pane_current_path}' # ^a alt2
bind M-3 split-window -v -p 30 -c '#{pane_current_path}' # ^a alt3
bind M-4 split-window -v -p 40 -c '#{pane_current_path}' # ^a alt4
bind M-5 split-window -v -p 50 -c '#{pane_current_path}' # ^a alt5
bind M-6 split-window -v -p 60 -c '#{pane_current_path}' # ^a alt6
bind M-7 split-window -v -p 70 -c '#{pane_current_path}' # ^a alt7
bind M-8 split-window -v -p 80 -c '#{pane_current_path}' # ^a alt8
bind M-9 split-window -v -p 90 -c '#{pane_current_path}' # ^a alt9
### resize pane
##set repeat-time 500
# time in which you can use another binding without using the prefix
# requires 'bind -r''
bind -r H resize-pane -L 2 # ^a H
bind -r J resize-pane -D 2 # ^a J
bind -r K resize-pane -U 2 # ^a K
bind -r L resize-pane -R 2 # ^a L
### swap panes
bind C-j swap-pane -D
bind C-k swap-pane -U
### copy-mode
unbind [
bind v copy-mode # ^a v
unbind ]
bind V paste-buffer # ^a V
### open man page
bind Enter command-prompt -p "Open man page for:" "new-window -n man 'exec colored-man %%'" # ^a ^m
### reload config
bind R source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded..." # ^a R
### maximize current pane (repeat to return/toggle off)
bind f run ~/scripts/tmux/maximize-pane
### remap ^l (clear) to ^a ^l
bind C-l send-keys "C-l"
### unbind suspension
unbind C-z
### open session list
bind w choose-tree -Zs
# '('/')' to go to prev/next session
## styling
### status bar
# colors: green=#00ff5f, blue=#005fd7, grey=#1c1c1c, red=#d70000, yellow=#ffff00
set -g status-bg "#1c1c1c"
set -g status-fg "#1c1c1c"
set -g status-interval 15 # update interval
set -g status-left "#[fg=#d70000,bg=#1c1c1c]"
set -g status-left-length 20 # cut-off
set -g status-right-length 50
set -q status-right "#[fg=#1c1c1c,bg=#ffff00]"
set -aq status-right "#(~/scripts/tmux/status/is-silent-playing)"
set -aq status-right "#[bg=#d70000]"
set -aq status-right "#(~/scripts/tmux/status/bluetooth.sh)"
set -aq status-right "#[bg=#ffff00]"
set -aq status-right "#(~/scripts/tmux/status/transmission.sh)"
# set -ag status-right "#(~/scripts/tmux/status/resolv.sh)"
set -aq status-right "#(~/scripts/tmux/status/hosts.sh)"
# status of lockdown mode
%if #{==:#{session_name},main}
set -aq status-right "#[fg=#d70000,bg=#1c1c1c]"
set -aq status-right "#[fg=#ffff00,bg=#d70000]#(pidof xss-lock >/dev/null || echo ' ')"
set -aq status-right "#[fg=#1c1c1c,bg=#d70000]#(pidof xss-lock >/dev/null && echo ' ')"
set -aq status-right "#[fg=#d70000,bg=#1c1c1c]"
set -aq status-right "#[fg=#1c1c1c,bg=#d70000] #(~/scripts/org/active-projects) "
%elif #{==:#{session_name},web}
set -aq status-right "#[fg=#d70000,bg=#1c1c1c]"
set -aq status-right "#[fg=#1c1c1c,bg=#d70000] #(~/scripts/personal/track-writing-progress) "
%endif
set -aq status-right "#[fg=#d70000,bg=#1c1c1c]"
### active windows
set -g window-status-current-format "#[fg=#1c1c1c,bg=#ffff00] #I #W "
set -g window-status-format "#[fg=#1c1c1c,bg=#005fd7] #I #W #[fg=#1c1c1c,bg=#005fd7]"
set -g window-status-separator "" # default is a space
set -g window-status-last-style fg=red,bold # last visited window
### pane divider
set -g pane-border-style fg="#6c6c6c"
set -g pane-active-border-style fg="#005fd7"
## layouts
### music
bind C-n new-window -n ncmpcpp "exec ncmpcpps" # ^a ^n
### ebook reader
bind b command-prompt -p "read:" "new-window -n book 'exec epr %%'" # ^a b
### file manager
bind C-f new-window -n lf\; send-keys 'lf $(open-lf)' "Enter" # ^a ^f
## tmux plugins
### resurrect - save/restore sessions (strg+s/strg+r)
# run-shell ~/scripts/tmux/tmux-resurrect/resurrect.tmux
# TODO: is this needed? tmuxinator sessions do this better
set -g bell-action none
set -g visual-bell off
# https://github.com/laktak/extrakto
run-shell ~/.local/share/tmux-plugins/extrakto/extrakto.tmux # ^a TAB
set -g @extrakto_split_size "8"
set -g @extrakto_copy_key "tab"
set -g @extrakto_insert_key "enter"
set -g @extrakto_split_direction "v"