-
Notifications
You must be signed in to change notification settings - Fork 0
/
.tmux.conf
144 lines (135 loc) · 5.29 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
# Preserve original value of TERM environment variable (mostly for vimrc)
set-environment -g PRESERVED_TERM $TERM
# Set appropriate new value of TERM environment variable, based on
# presence of tmux terminfo file(s), and support of 256 colors.
#
# This is required, because while the modern versions of ncurses support the
# tmux terminfo definition, the older versions (e.g. the default on 2022's
# macOS) does _not_.
# This also allows for the automatic adjustment in case the tmux alone does not
# manage to set the TERM environment variable properly.
#
# On the other hand, it is better if `tmux` TERM is chosen over `screen` TERM,
# because the latter does not support italics, so the default to `screen*` would
# be suboptimal
if-shell "infocmp tmux && infocmp tmux-256color" {
set-environment -g TMUX_TERM_PREFIX tmux
} {
set-environment -g TMUX_TERM_PREFIX screen
}
# It doesn't work if braces ({}) syntax is used (I wasn't able to find why;
# tmux man pages don't explain the evaluation rules inside single quotes)
if-shell "echo $TERM | grep 256color" \
'set -g default-terminal $TMUX_TERM_PREFIX-256color' \
'set -g default-terminal $TMUX_TERM_PREFIX'
# Set complex or simple status depending on the OS (see the `Status line`
# section below for details)
if-shell '[ -z ${TMUX_SIMPLE_STATUS+x} ]' {
if-shell "uname -s | grep -iq 'darwin'" {
set-environment -g TMUX_SIMPLE_STATUS false
} {
set-environment -g TMUX_SIMPLE_STATUS true
}
}
# Assume that otherwise this is (Arch) Linux
if-shell "uname -s | grep -iq 'darwin'" \
'set-environment -g TMUX_OS_PACKAGE_MANAGER brew' \
'set-environment -g TMUX_OS_PACKAGE_MANAGER pacman'
# Start indexing of windows and panes from 1, not 0
set -g base-index 1
setw -g pane-base-index 1
################
### Bindings ###
################
# Rebind prefix
set -g prefix C-q
unbind-key C-b
bind-key C-q send-prefix
# Vim-like split
bind-key s split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
# Vim-like panes manipulation
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
bind-key -r C-h resize-pane -L
bind-key -r C-j resize-pane -D
bind-key -r C-k resize-pane -U
bind-key -r C-l resize-pane -R
bind-key -r M-h resize-pane -L 5
bind-key -r M-j resize-pane -D 5
bind-key -r M-k resize-pane -U 5
bind-key -r M-l resize-pane -R 5
# Vi copy mode
set-window-option -g mode-keys vi
# Not working on current version
# bind-key -t vi-copy v begin-selection
# bind-key -t vi-copy y copy-selection
# Etc
bind-key Q confirm-before -p 'kill-session? (y/n)' kill-session
bind-key C new-window -n 'etc' -t 0
# Reload the configuration file and refresh the status line
bind-key S source-file ~/.tmux.conf \; refresh-client -S
###################
### Status line ###
###################
# colour15 => bright white
# colour69 => bluey-violet
# On the macOS the complex status is enabled by default, while on other
# operating systems the simple status is enabled by default.
# To switch to the simple status for the current session, run:
# ```
# $ tmux setenv -g TMUX_SIMPLE_STATUS 1
# ```
# To switch to the complex status for the current session, run:
# ```
# $ tmux setenv -gu TMUX_SIMPLE_STATUS
# ```
#
# The complex status contains system info including CPU load, memory usage, etc.
# This is helpful on operating systems that does not allow to easily customize
# this into the menu bar (e.g. macOS, Linux without graphical environment). On
# other operating systems (e.g. Linux with XFCE), the simple status is
# recommended.
if-shell '[ "${TMUX_SIMPLE_STATUS}" = true ]' {
setw -g status-left ' '
setw -g status-right '#{?client_prefix,^Q , }'
setw -g status-justify centre
} {
setw -g status-right-length 88
setw -g status-left ''
setw -g status-right '#{?client_prefix,^Q , }#(while :; do status-outdated-packages -P #{TMUX_OS_PACKAGE_MANAGER} tmux; sleep 3600; done) | #(status-load-average tmux) | #(status-memory tmux) | #(status-disk tmux)'
setw -g status-justify left
# EXPERIMENT: see if less frequent update of the status line (by default
# it's 15 seconds) decreases the user experience. If not, leave the new
# value; no reason to update the status so often if it doesn't give any
# advantage
set -g status-interval 60
}
setw -g status-bg black
setw -g status-fg colour15
setw -g window-status-style "fg=colour15 bg=black"
setw -g window-status-format ' #I #W '
setw -g window-status-current-style "fg=black bg=colour69"
setw -g window-status-current-format ' #I #W '
setw -g pane-border-style fg=colour15
setw -g pane-active-border-style fg=colour69
setw -g display-panes-colour colour15
setw -g display-panes-active-colour colour69
setw -g clock-mode-colour colour69
###############
### Plugins ###
###############
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# Too often, I was mistaking the default key bindings (C-s and C-r) with my
# custom key binding for reloading the configuration (S), which lead to
# overwriting the saved environment accidentally
set -g @resurrect-save 'M-s'
set -g @resurrect-restore 'M-r'
# Check if tpm plugin manager is installed
if-shell '[ -f ~/.tmux/plugins/tpm/tpm ]' {
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
}