-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
tmux.conf
177 lines (151 loc) · 6.83 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
# Usage, inside tmux (note, my prefix is Ctrl-w):
# Alt-w: create a new window (preserving cwd)
# Alt-[1/2/..]: switch to numbered window
# Alt-l: switch to the Last window
# Alt-a: switch to (A)djacent pane
# Alt-v / Prefix-|: create (V)ertical split pane (preserving cwd)
# Alt-s / Prefix--: create horizontal (S)plit pane (preserving cwd)
# Alt-r: (R)ename the current window
# Alt-z: toggle pane (Z)oom between full size and normal pane size
# Alt-y: toggle "s(Y)nchronize" to all panes of the current window
# Alt-x: e(X)change session
# Alt-</>: move panes around current window.
# Prefix-d: detach session
# Prefix-x: kill a window
# Prefix-w: list all windows
#
# Usage, copy and paste inside tmux:
# Alt-ESCAPE: enter copy mode, use vi keys for navigation (h,j,k,l,H,M,L,g,G,/,?)
# v: start selection
# y or Enter: end selection
# Alt-p: paste selection
# Alt-=: view all paste buffers, then paste selection
#
# Note, hold "Shift" if one wishes to copy and paste into or out-of tmux
# using mouse selections.
#
# Usage, at command line:
# tmux new -s foglamp: create a new session named foglamp
# tnew: bash alias to create a session named using the current directory
# tmux ls: list active sessions
# tmux attach: attach to first active session
# tmux attach -t foglamp: attach to session named "foglamp".
#============================
# Configuration
#============================
# Change the default prefix.
unbind-key C-b
set -g prefix C-w
# Default terminal.
#
# Note, the terminal should be either 'screen*' or 'tmux*', not 'xterm-256color'
# or 'alacritty' as explained here: https://github.com/tmux/tmux/wiki/FAQ
set -g default-terminal "tmux-256color"
# Hack to get clipboard working on Mac.
# Reference: https://github.com/tmux/tmux/issues/543
if-shell '[[ "$OS" = "Darwin" ]]' \
'set -g default-command "reattach-to-user-namespace -l ${SHELL}"'
# Needed for CTRL-Left/Right to work.
set -g xterm-keys on
# Allow 256 and true colour support for Alacritty.
set -ga terminal-overrides ',alacritty:Tc'
# Allow undercurls for terminals that support them.
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
# Allow coloured undercurls for terminals that support them.
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
# Set the status bar attributes.
set -g status-left-length 40
set -g status-interval 30
# Make Vim more responsive.
set -sg escape-time 0
# Increase scroll back limit.
set -g history-limit 10000
# Use vi key bindings in copy mode.
set -g mode-keys vi
# Window and pane numbering should be 1-based.
set -g base-index 1
set -g pane-base-index 1
# Renumber windows when one is closed.
set -g renumber-windows on
# Highlight window when it has new activity, but do not display an alert.
set -g monitor-activity on
set -g visual-activity off
# Enable mouse support including pane focusing and selection support.
set -g mouse on
# Stop all Docker containers when closing a session.
set-hook -g session-closed 'run-shell "docker container stop $(docker container ls --all --quiet) 1> /dev/null 2> /dev/null"'
#============================
# Bindings
#============================
# Mouse behaviours.
unbind-key -Tcopy-mode-vi MouseDragEnd1Pane
bind-key -Tcopy-mode-vi MouseDown1Pane send -X clear-selection
# Use Vim style commands for copy and paste. See "Usage, copy and paste" above.
unbind-key [
bind-key -n M-Escape copy-mode
unbind-key p
bind-key -n M-p paste-buffer
bind-key -n M-= choose-buffer
bind-key -T copy-mode-vi v send -X begin-selection
# Copy tmux selection to system clipboard. Different mechanisms are needed for
# Linux and Mac. Allow both Enter and 'y' (for yank) to signify end selection.
# Note, use 'wl-copy' for Wayland.
if-shell 'case "$OS" in *Linux*) true;; *) false;; esac' \
'bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "xclip -selection primary -i -f | xclip -selection clipboard -i"' \
'bind-key -T copy-mode-vi Enter send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"'
if-shell 'case "$OS" in *Linux*) true;; *) false;; esac' \
'bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -selection primary -i -f | xclip -selection clipboard -i"' \
'bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"'
# Reload tmux.conf via Prefix-r.
bind-key r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
# Nicer split window bindings.
unbind-key %
bind-key | split-window -h -c "#{pane_current_path}"
unbind-key '"'
bind-key - split-window -v -c "#{pane_current_path}"
# Simple, non-prefixed, mappings.
bind-key -n M-w new-window -c "#{pane_current_path}" # Create (W)indow
bind-key -n M-z resize-pane -Z # Toggle (Z)oom
bind-key -n M-v split-window -h -c "#{pane_current_path}" # (V)ertical split
bind-key -n M-s split-window -v -c "#{pane_current_path}" # Horizontal (S)plit
bind-key -n M-r command-prompt -I "" "rename-window '%%'" # (R)ename window
bind-key -n M-y setw synchronize-panes # S(Y)nchronize panes
bind-key -n M-l last-window # (L)ast window
bind-key -n M-a select-pane -t :.+ # (A)djacent pane
bind-key -n M-x choose-session # E(X)change session
bind-key -n M-< swap-pane -D # Swap pane backward
bind-key -n M-> swap-pane -U # Swap pane forward
# Switch windows using Alt-<number>.
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
bind-key -n M-4 select-window -t 4
bind-key -n M-5 select-window -t 5
bind-key -n M-6 select-window -t 6
bind-key -n M-7 select-window -t 7
bind-key -n M-8 select-window -t 8
bind-key -n M-9 select-window -t 9
#============================
# Style
#
# Symbols:
# * Current window.
# - Alternate/last window
# # Window activity detected
# Z Window's active pane is zoomed
#============================
# Set status line, windows, pane and message colors.
set -g message-style "bg=#1c1c1c,fg=#9c9c9c"
set -g pane-active-border-style "bg=#080808,fg=#80a0ff"
set -g pane-border-style "bg=#080808,fg=#303030"
set -g status-style "bg=#1c1c1c,fg=#9c9c9c"
setw -g window-status-activity-style none
setw -g window-status-current-style "bg=#353946,fg=#80a0ff"
# Set active and inactive window style.
setw -g window-status-current-format " #I #[fg=#9c9c9c] #[fg=default]#W #[fg=#e65e72]#{?window_flags,#{window_flags}, }#[fg=default] "
setw -g window-status-format " #I #W #[fg=#e65e72]#{?window_flags,#{window_flags}, }#[fg=default] "
# Set status bar components and style.
set -g status-left "#[fg=#f09479]⠶ #[fg=#80a0ff]#S@#h "
if-shell '[[ $(uname) = Darwin ]]' \
'set -g status-right "%a %d %b #[fg=#80a0ff]%I:%M%p"' \
'set -g status-right "%a %d %b #[fg=#80a0ff]%I:%M%P"' \