-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
142 lines (115 loc) · 5.06 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
# Create variable for version-specific commands.
# https://github.com/tmux/tmux/blob/master/CHANGES
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6- | tr -d '[:alpha:]')"
# Use Ctrl-a as activation key like screen.
set-option -g prefix C-a
unbind C-b
# Re-source this configuration file with C-b r.
bind-key r source-file ~/.tmux.conf \; display "~/.tmux.conf sourced!"
# Use Ctrl-a Ctrl-a to toggle between windows like screen.
bind-key C-a last-window
# Screen doesn't mind if you hold down Ctrl while making a new window.
bind-key C-c new-window
# Forward on the Ctrl-a like screen.
bind-key a send-prefix
# Emulate hardcopy like screen.
bind-key H capture-pane -b 0 \; save-buffer -b 0 ~/tmux.hardcopy \; delete-buffer -b 0
# Begin window numbering at 1.
# 0-indexing is neat, but 0 is the other side of the keyboard.
set-option -g base-index 1
# Re-number windows to maintain gapless window indexes.
set-window-option -g renumber-windows on
# Grab another window and create a pane in the current window with it.
bind-key J command-prompt -p "join pane from:" "join-pane -v -s '%%'"
bind-key j command-prompt -p "join pane from:" "join-pane -h -s '%%'"
# Move current window left or right by one position.
bind-key M swap-window -t -1
bind-key m swap-window -t +1
# Toggle synchronize-panes to broadcast type in all panes at once.
bind-key C-b set-window-option synchronize-panes
set-window-option -g window-status-current-format '#{?pane_synchronized,#[bg=red],}#I:#W'
set-window-option -g window-status-format '#{?pane_synchronized,#[bg=red],}#I:#W'
# Move windows with shift/arrows.
# Also works around Vim issue of receiving unknown keycodes.
#bind-key -n S-Left previous-window
#bind-key -n S-Right next-window
# Moving windows can be annoying, so just do nothing but prevent the keycode
# from reaching Vim.
bind-key -n S-Left set-buffer ''
bind-key -n S-Right set-buffer ''
# New windows should open in the original directory (default), but new panes
# should open in the same directory as the current pane.
# https://github.com/tmux/tmux/blob/5391342b08f746239e3d0e2f729410af10a54b78/CHANGES#L199
if-shell -b '[ "$(echo "0$TMUX_VERSION < 1.9" | bc)" = 0 ]' " \
bind-key % split-window -h -c '#{pane_current_path}'; \
bind-key '\"' split-window -v -c '#{pane_current_path}'; \
"
# Enable mouse control.
if-shell -b '[ "$(echo "0$TMUX_VERSION < 2.1" | bc)" = 1 ]' " \
set-option -g mode-mouse on; \
set-option -g mouse-resize-pane on; \
set-option -g mouse-select-pane on; \
set-option -g mouse-select-window on; \
"
# Since v2.1 there is only one mouse option.
if-shell -b '[ "$(echo "0$TMUX_VERSION < 2.1" | bc)" = 0 ]' " \
set-option -g mouse on; \
"
# Enable vi controls for copy mode.
set-option -g status-keys vi
set-window-option -g mode-keys vi
if-shell -b '[ "$(echo "0$TMUX_VERSION < 2.4" | bc)" = 1 ]' " \
bind-key -t vi-copy 'v' begin-selection; \
bind-key -t vi-copy 'y' copy-selection; \
"
# Since v2.4, keybinding syntax has changed.
if-shell -b '[ "$(echo "0$TMUX_VERSION < 2.4" | bc)" = 0 ]' " \
bind-key -T copy-mode-vi v send-keys -X begin-selection; \
bind-key -T copy-mode-vi y send-keys -X copy-selection; \
"
# Resize current window.
set-window-option -g aggressive-resize on
# Use ISO8601 date/time in statusline.
set-option -g status-right-style fg=white,bg=red
set-option -g status-right "%a %Y-%m-%d %H:%M:%S"
set-option -g status-interval 1
# Highlight active window in statusline.
if-shell -b '[ "$(echo "0$TMUX_VERSION < 2.9" | bc)" = 1 ]' " \
set-window-option -g window-status-current-bg blue; \
set-window-option -g window-status-current-fg white; \
"
# Since v2.9 style syntax has changed.
if-shell -b '[ "$(echo "0$TMUX_VERSION < 2.9" | bc)" = 0 ]' " \
set-window-option -g window-status-current-style bg=blue,fg=white; \
"
# Display status messages for more than the default 0.75s.
set-option -g display-time 2000
# Use xterm instead of screen for TERM.
set-option -g default-terminal "screen-256color"
# Normal backspace behaviour.
#send-keys "stty erase '^?'" Enter
set-window-option -g xterm-keys
# Send Esc immediately, as I don't use any Alt+? key combinations.
set-option -g escape-time 0
# I don't have any repeat keys, so finish command immediately.
# This removes the annoying behaviour when changing panes then pressing up to
# go through history.
set-option -g repeat-time 0
# Prevent flooding of STDOUT from locking up terminal.
# Limit output to 150 newlines per 100ms so the host terminal (xterm, Gnome
# Terminal, LXTerminal, etc) won't get stuck rendering too much text.
# Annoyingly, these have been removed and replaced with a non-functional
# backoff rate limiter.
if-shell -b '[ "$(echo "0$TMUX_VERSION < 2.0" | bc)" = 1 ]' " \
set-option -g c0-change-trigger 150; \
set-option -g c0-change-interval 100; \
"
# tmux plugin manager
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# tmux-resurrect/continuum
set -g @resurrect-capture-pane-contents 'on'
#set -g @resurrect-strategy-vim 'session'
set -g @continuum-save-interval '5'
run '~/.tmux/plugins/tpm/tpm'