forked from HariSekhon/DevOps-Bash-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
220 lines (174 loc) · 8.37 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
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2015-10-08 12:10:02 +0100 (Thu, 08 Oct 2015)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
# Run 'make tmux' to install TPM before using this config or see git clone at bottom
# ============================================================================ #
# T M U X C o n f i g u r a t i o n
# ============================================================================ #
# Ctrl-b r - reloads .tmux.conf
# remember tmux reuses backend server process which doesn't go down unless you do 'tmux kill-server' (killing tmux server process is an easy reset if you don't want to undo options you've been messing with interactively)
bind r source-file ~/.tmux.conf \; display ".tmux.conf reloaded"
# Ctrl-b b - reloads .bashrc - .bash.d/aliases.sh 'r' enter keystroke is easier to type
#bind b send-keys "source ~/.bashrc" "Enter" \; display ".bashrc reloaded"
# 'tmux attach' starts new session if none exists
# when combined with reloading above, however, causing a new session to be created every time
#new-session
#attach
# ============================================================================ #
# change default meta key from Ctrl-b to Ctrl-a to be more like screen
#
# seemed like a good idea initially until working on various companies servers and your muscle memory is wrong or
# you need to embed screen and tmux sessions (eg. screen on laptop, tmux on remote server) without having to double escape meta keys
#
#unbind C-b
#set -g prefix C-a
#
# sends meta through to other apps eg. screen
#bind C-a send-prefix
#bind a send-prefix
# ============================================================================ #
# S t a t u s B a r
# ============================================================================ #
# based on my screen colour style - might be better to leave tmux looking distinct with it's original block green
# more complex multi-colours now set in window-status-format / window-current-status-format below instead
# need this to stay set to make sure status-separator doesn't revert to bg=green
set -g status-style "bg=black fg=brightgreen"
# ========================================
# window list - setting to red if panes are synchronized
# #I - window index
# #W - window name
setw -g window-status-current-format "#[bg=black fg=red][#{?pane_synchronized,#[bg=brightred fg=white],#[bg=black fg=brightblue]}#I* #W#[bg=black fg=red]]"
setw -g window-status-format "#{?pane_synchronized,#[bg=brightred fg=white],#[bg=black fg=brightgreen]} #I #W"
setw -g window-status-separator " "
# toggle sending keystrokes to all panes in split - quick way of multi-commanding servers (like cssh back in the day)
bind y set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'
# ========================================
setw -g monitor-activity on
#setw -g window-status-activity-style "bg=black fg=magenta"
# ========================================
# Status Left
set -g status-left "#[bg=black fg=green][ #[fg=magenta]#h #[bg=black fg=green] | #S | "
set -g status-left-length 50
# ========================================
# Status Right
#
# #{battery_percentage} - Mac shows battery percentage at top right so don't need this
# #{online_status} - tmux-plugins/tmux-online-status - causes climbing duplicate status bars at bottom
# #(bash ~/.tmux/plugins/kube.tmux 250 magenta green) - may not have kubernetes, also expensive to re-execute this every 5 secs
# Continuum: #{continuum_status}
set -g status-right "#[bg=black fg=green]| %H:%M %d/%b/%Y ]"
#set -g status-right-length 100
#%if #{TMUX}
#set -g status-bg red
#%endif
# ============================================================================ #
# S e t t i n g s
# ============================================================================ #
# set is short for set-option
# -g = global
# -s = server / session
# -u = unsets session to inherit global, or resets global to default with -g
# -o = prevents resetting an already set value
# -a = appends to current value
# show all settings:
#
# tmux show -g
# don't auto-rename windows
# set-option -g allow-rename off
set -g status-justify left # or centre
setw -g alternate-screen on # default, restore previous contents when exiting interactive app
set -g bell-action none
set -g visual-bell off
# renumber windows when one closes
set -g renumber-windows on
set -g focus-events on
# if this line gives you an 'ambiguous' error, upgrade tmux
set -g mouse on
# disable copy-mode dragging
#unbind -n MouseDrag1Pane
#unbind -Tcopy-mode MouseDrag1Pane
#set -g base-index 1 # start window count from 1 instead of 0
#setw -g pane-base-index 1 # start pane count from 1 instead of 0
# ===============================
# these are set in tmux-sensible
#
#setw -g utf8 on
#set -g status-interval 15 # default: 15 - how often to redraw status and execute tmux plugins
#set -g default-terminal "screen-256color" # force assuming colors without 'tmux -2' or TERM environment variable
set -g history-limit 100000 # give us even bigger history than tmux-sensible
# ============================================================================ #
# K e y b i n d i n g s
# ============================================================================ #
# be more like screen to toggle between last window - no longer used as interferes with portal muscle memory when working on various companies servers
#bind b last-window
#bind-key C-c run-shell "tmux show-buffer | xclip -i"
#bind-key C-v run-shell "tmux set-buffer \\"$(xclip -o)\\"; tmux paste-buffer"
# millis to wait a key after meta - default is 500ms
# set higher for remote servers with latency
# set lower for local sessions for speed / responsiveness
set -s escape-time 1
# use expanded view - default is choose-tree view which lists sessions collapsed
#bind s choose-tree -u
# don't recommend changing these from the defaults if you work on other people's servers as a consultant
#bind | split-window -h
#bind - split-window -v
# retain $PWD when splitting
#bind _ split-window -v -c "#{pane_current_path}"
#bind \ split-window -h -c "#{pane_current_path}"
# ====================================
# shortcuts to higher numbered windows
bind F1 selectw -t:10
bind F2 selectw -t:11
bind F3 selectw -t:12
bind F4 selectw -t:13
bind F5 selectw -t:14
bind F6 selectw -t:15
bind F7 selectw -t:16
bind F8 selectw -t:17
bind F9 selectw -t:18
bind F10 selectw -t:19
bind F11 selectw -t:20
bind F12 selectw -t:21
#toggle between smallest and largest sizes if a window is visible in multiple places
#bind F set -w window-size
# switch panes with Alt-arrow
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
# ============================================================================ #
# T M U X p l u g i n s
# ============================================================================ #
# Ctrl-b I to fetch plugins
set -g @plugin 'tmux-plugins/tmux-sensible' # options everyone should be ok with
set -g @plugin 'tmux-plugins/tmux-resurrect' # Ctrl-b Ctrl-s to save sessions, Ctrl-b Ctrl-r to restore
set -g @plugin 'tmux-plugins/tmux-continuum' # needs tmux-resurrect
set -g @plugin 'tmux-plugins/tmux-urlview'
#set -g @plugin 'tmux-plugins/tmux-online-status' # overkill, just call .bash.d/ functions & aliases when needed
#set -g @plugin 'tmux-plugins/tmux-pain-control'
#set -g @plugin 'tmux-plugins/tmux-battery' # Mac shows this at top right so don't need these bash scripts
set -g @continuum-save-interval '15' # default: 15, set to 0 to stop automatic saving
set -g @continuum-restore 'on' # automatic restore
set -g @continuum-boot 'on' # auto-start terminal at boot
set -g @continuum-boot-options 'fullscreen'
# if icons don't display properly set this
#set -g @online_icon "ok"
#set -g @offline_icon "offline!"
# ============
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
#
# download TPM like so before launching/reloading tmux:
#
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
#
run -b '~/.tmux/plugins/tpm/tpm'