Text · 2801 bytes Raw Blame History
1 ##### keybinds (+ global ON/OFF like Zellij’s Ctrl-G) #####
2
3 # Global switch: when OFF, your custom binds are paused and keys pass to apps.
4 set -g @ui_binds on
5
6 # Toggle (Ctrl+g) — refresh status immediately so colors/badge update
7 unbind -n C-g
8 bind -n C-g if-shell -F '#{==:#{@ui_binds},on}' \
9 "set -g @ui_binds off; refresh-client -S; display-message 'User binds: OFF (Ctrl+g to re-enable)'" \
10 "set -g @ui_binds on; refresh-client -S; display-message 'User binds: ON'"
11
12 # Helper pattern for guarded binds:
13 # unbind -n <KEY>
14 # bind -n <KEY> if-shell -F '#{==:#{@ui_binds},on}' "<tmux action>" "send-keys <KEY>"
15
16 ##### Tabs / windows #####
17
18 # New tab
19 unbind -n C-t
20 bind -n C-t if-shell -F '#{==:#{@ui_binds},on}' \
21 "new-window" \
22 "send-keys C-t"
23
24 # Close tab (confirm)
25 unbind -n C-w
26 bind -n C-w if-shell -F '#{==:#{@ui_binds},on}' \
27 "confirm-before -p 'Kill window #W? (y/n)' kill-window" \
28 "send-keys C-w"
29
30 # Previous / Next tab
31 unbind -n C-M-Left
32 bind -n C-M-Left if-shell -F '#{==:#{@ui_binds},on}' \
33 "previous-window" \
34 "send-keys C-M-Left"
35
36 unbind -n C-M-Right
37 bind -n C-M-Right if-shell -F '#{==:#{@ui_binds},on}' \
38 "next-window" \
39 "send-keys C-M-Right"
40
41 ##### Panes / splits #####
42
43 # Split left/right (vertical divider)
44 unbind -n M-\\
45 bind -n M-\\ if-shell -F '#{==:#{@ui_binds},on}' \
46 "split-window -h" \
47 "send-keys M-\\"
48
49 # Split top/bottom (horizontal divider)
50 unbind -n "M-|"
51 bind -n "M-|" if-shell -F '#{==:#{@ui_binds},on}' \
52 "split-window -v" \
53 "send-keys M-\|"
54
55 # Close pane (confirm)
56 unbind -n C-S-x
57 bind -n C-S-x if-shell -F '#{==:#{@ui_binds},on}' \
58 "confirm-before -p 'Kill pane #P? (y/n)' kill-pane" \
59 "send-keys C-x" # tmux can’t reliably synthesize C-S-x; pass through C-x
60
61 ##### Pane focus #####
62
63 unbind -n C-M-S-Left
64 bind -n C-M-S-Left if-shell -F '#{==:#{@ui_binds},on}' \
65 "select-pane -L" \
66 "send-keys C-M-S-Left"
67
68 unbind -n C-M-S-Right
69 bind -n C-M-S-Right if-shell -F '#{==:#{@ui_binds},on}' \
70 "select-pane -R" \
71 "send-keys C-M-S-Right"
72
73 unbind -n C-M-S-Up
74 bind -n C-M-S-Up if-shell -F '#{==:#{@ui_binds},on}' \
75 "select-pane -U" \
76 "send-keys C-M-S-Up"
77
78 unbind -n C-M-S-Down
79 bind -n C-M-S-Down if-shell -F '#{==:#{@ui_binds},on}' \
80 "select-pane -D" \
81 "send-keys C-M-S-Down"
82
83 ##### Pane resize #####
84
85 unbind -n M-S-Left
86 bind -n M-S-Left if-shell -F '#{==:#{@ui_binds},on}' \
87 "resize-pane -L 5" \
88 "send-keys M-S-Left"
89
90 unbind -n M-S-Right
91 bind -n M-S-Right if-shell -F '#{==:#{@ui_binds},on}' \
92 "resize-pane -R 5" \
93 "send-keys M-S-Right"
94
95 unbind -n M-S-Up
96 bind -n M-S-Up if-shell -F '#{==:#{@ui_binds},on}' \
97 "resize-pane -U 2" \
98 "send-keys M-S-Up"
99
100 unbind -n M-S-Down
101 bind -n M-S-Down if-shell -F '#{==:#{@ui_binds},on}' \
102 "resize-pane -D 2" \
103 "send-keys M-S-Down"
104