-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux.conf
138 lines (119 loc) · 5.08 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
# NOTE: make image preview in kitty work
set -g allow-passthrough on
# NOTE: prefix
set -g prefix M-a
bind M-a send-prefix
unbind C-b
set -g status-style fg=default,fg=default
# set -g base-index 1
# set -g pane-base-index 1
set -g mouse on
set -g cursor-style bar
# https://superuser.com/a/1809494/1824899
set -sg escape-time 5
set -g history-limit 50000
set -g display-time 4000
set -g status-interval 5
set -g status-keys emacs
set -g focus-events on
set-window-option -g aggressive-resize on
set-window-option -g mode-keys vi
# NOTE: status bar look
set -g status-position top
set -g status-left '#{?client_prefix,#[bg=red],} #S '
set -g status-right ''
set-window-option -g window-status-format ' #{?window_zoomed_flag,,} #I: #W '
set-window-option -g window-status-current-format '#{?window_active,#[bg=yellow],} #{?window_zoomed_flag,,} #I: #W '
# Make colorscheme in neovim works
# See relevant question on stackoverflow: https://stackoverflow.com/a/60313682
# This works for ArchLinux, alacritty
set-option -ga terminal-overrides ",xterm-256color:Tc"
# Quick refresh of tmux config
unbind M-s
bind M-s source-file ~/.config/tmux/tmux.conf
# Session management
unbind s
unbind x
bind M-q switchc -p # prefix M-q switch to previous session
bind M-e switchc -n # prefix M-e switch to next session
bind M-t new-session
unbind r
bind r command-prompt -I "" { rename-session "%%" } # prefix r to rename session
bind M-r command-prompt -I "" { rename-session "%%" } # prefix r to rename session
bind x kill-session
# Windows Management
bind p resize-pane -Z #zoom
bind d split-window -h -c '#{pane_current_path}' # vertical split
bind a split-window -v -c '#{pane_current_path}' # horizontal split
bind x set-option status # toggle status bar
unbind %
unbind 0
unbind 1
unbind 2
unbind 3
unbind 4
unbind 5
unbind 6
unbind 7
unbind 8
unbind 9
bind \\ split-window -h -c '#{pane_current_path}' # vertical split, semantic keybinding!!!
bind D detach-client
unbind '"'
bind - split-window -v -c '#{pane_current_path}' # horizontal split, semantic keybinding!!!
bind -r J resize-pane -D 4
bind -r K resize-pane -U 4
bind -r L resize-pane -R 4
bind -r H resize-pane -L 4
bind -r m resize-pane -Z # maximize/unmaximize pane
bind h select-pane -L # select pane on left
bind j select-pane -D # select pane on bottom
bind k select-pane -U # select pane on top
bind l select-pane -R # select pane on right
bind -n M-t new-window -c "#{pane_current_path}"
bind -n M-q previous-window
bind -n M-e next-window
bind f display-popup -E -x20% -y20% -h40% -w80% "$HOME/bin/tmux-window"
# NOTE: popup for editing oldfiles
bind s display-popup -E -x20% -y20% -h80% -w80% nvim
bind -n M-w kill-pane
# bind -n M-0 kill-pane -a
bind -n M-r command-prompt -I "#W" { rename-window "%%" }
# Copy mode like vim
bind -n M-x copy-mode
# NOTE: if programs specified in `TMUX_YANK_NOT_CANCEL_PAT` are running in current pane
# don't exit copy-mode after yanking, otherwise quit copy mode after yanking
bind -T copy-mode-vi 'y' if-shell "$HOME/bin/tmux-yank #{pane_tty}" {
send-keys -X copy-selection
} {
send-keys -X copy-selection-and-cancel
}
bind -T copy-mode-vi 'Y' send-keys -X copy-selection-and-cancel
unbind -T copy-mode-vi H
unbind -T copy-mode-vi L
unbind -T copy-mode-vi J
unbind -T copy-mode-vi K
unbind -T copy-mode-vi MouseDragEnd1Pane
unbind -T copy-mode-vi C-v
bind -T copy-mode-vi 'v' send -X begin-selection
bind -T copy-mode-vi 'H' send -X start-of-line
bind -T copy-mode-vi 'L' send -X end-of-line
bind -T copy-mode-vi 'K' send -X halfpage-up
bind -T copy-mode-vi 'J' send -X halfpage-down
bind -T copy-mode-vi Escape send -X clear-selection
bind -T copy-mode-vi 'i' send -X cancel
bind -T copy-mode-vi 'a' send -X cancel
bind -T copy-mode-vi 'q' send -X cancel
bind -T copy-mode-vi ? command-prompt -T search -p "(search down)" { send-keys -X search-forward "%%" }
bind -T copy-mode-vi / command-prompt -T search -p "(search up)" { send-keys -X search-backward "%%" }
bind-key -n 'C-j' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-j } { if-shell -F '#{pane_at_bottom}' {} { select-pane -D } }
bind-key -n 'C-k' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-k } { if-shell -F '#{pane_at_top}' {} { select-pane -U } }
bind-key -T copy-mode-vi 'C-j' if-shell -F '#{pane_at_bottom}' {} { select-pane -D }
bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane -U }
bind-key -n 'C-h' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-h } {
if-shell -F '#{pane_at_left}' { previous-window } { if-shell '[[ #W =~ nnn ]]' { previous-window } { select-pane -L }}}
bind-key -n 'C-l' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-l } {
if-shell -F '#{pane_at_right}' { next-window } { if-shell '[[ #W =~ nnn ]]' { next-window } { select-pane -R }}}
bind-key -T copy-mode-vi 'C-h' if-shell -F '#{pane_at_left}' { previous-window } { if-shell '[[ #W =~ nnn ]]' { previous-window } { select-pane -L }}
bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' { next-window } { if-shell '[[ #W =~ nnn ]]' { next-window } { select-pane -R }}
bind C-l send-keys 'C-l'