| 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 M-j |
| 37 | # bind -n M-j if-shell -F '#{==:#{@ui_binds},on}' \ |
| 38 | # "previous-window" \ |
| 39 | # "send-keys M-j" |
| 40 | |
| 41 | unbind -n C-M-Right |
| 42 | bind -n C-M-Right if-shell -F '#{==:#{@ui_binds},on}' \ |
| 43 | "next-window" \ |
| 44 | "send-keys C-M-Right" |
| 45 | |
| 46 | # unbind -n M-l |
| 47 | # bind -n M-l if-shell -F '#{==:#{@ui_binds},on}' \ |
| 48 | # "next-window" \ |
| 49 | # "send-keys M-l" |
| 50 | |
| 51 | ##### Panes / splits ##### |
| 52 | |
| 53 | # Split left/right (vertical divider) |
| 54 | unbind -n M-\\ |
| 55 | bind -n M-\\ if-shell -F '#{==:#{@ui_binds},on}' \ |
| 56 | "split-window -h" \ |
| 57 | "send-keys M-\\" |
| 58 | |
| 59 | # Split top/bottom (horizontal divider) |
| 60 | unbind -n "M-|" |
| 61 | bind -n "M-|" if-shell -F '#{==:#{@ui_binds},on}' \ |
| 62 | "split-window -v" \ |
| 63 | "send-keys M-\|" |
| 64 | |
| 65 | # Kill pane with Alt+Shift+W (guarded; passes through when binds OFF) |
| 66 | unbind -n M-W |
| 67 | bind -n M-W if-shell -F '#{==:#{@ui_binds},on}' \ |
| 68 | "confirm-before -p 'Kill pane #P? (y/n)' kill-pane" \ |
| 69 | "send-keys M-W" |
| 70 | |
| 71 | # Backup: Ctrl+Alt+w also kills the pane (guarded) |
| 72 | unbind -n C-M-w |
| 73 | bind -n C-M-w if-shell -F '#{==:#{@ui_binds},on}' \ |
| 74 | "confirm-before -p 'Kill pane #P? (y/n)' kill-pane" \ |
| 75 | "send-keys C-M-w" |
| 76 | |
| 77 | ##### Pane focus ##### |
| 78 | |
| 79 | unbind -n C-S-Left |
| 80 | bind -n C-S-Left if-shell -F '#{==:#{@ui_binds},on}' \ |
| 81 | "select-pane -L" \ |
| 82 | "send-keys C-S-Left" |
| 83 | |
| 84 | unbind -n M-J |
| 85 | bind -n M-J if-shell -F '#{==:#{@ui_binds},on}' \ |
| 86 | "select-pane -L" \ |
| 87 | "send-keys M-J" |
| 88 | |
| 89 | unbind -n C-S-Right |
| 90 | bind -n C-S-Right if-shell -F '#{==:#{@ui_binds},on}' \ |
| 91 | "select-pane -R" \ |
| 92 | "send-keys C-S-Right" |
| 93 | |
| 94 | unbind -n M-L |
| 95 | bind -n M-L if-shell -F '#{==:#{@ui_binds},on}' \ |
| 96 | "select-pane -R" \ |
| 97 | "send-keys M-L" |
| 98 | |
| 99 | unbind -n C-S-Up |
| 100 | bind -n C-S-Up if-shell -F '#{==:#{@ui_binds},on}' \ |
| 101 | "select-pane -U" \ |
| 102 | "send-keys C-S-Up" |
| 103 | |
| 104 | unbind -n M-I |
| 105 | bind -n M-I if-shell -F '#{==:#{@ui_binds},on}' \ |
| 106 | "select-pane -U" \ |
| 107 | "send-keys M-I" |
| 108 | |
| 109 | unbind -n C-S-Down |
| 110 | bind -n C-S-Down if-shell -F '#{==:#{@ui_binds},on}' \ |
| 111 | "select-pane -D" \ |
| 112 | "send-keys C-S-Down" |
| 113 | |
| 114 | unbind -n M-K |
| 115 | bind -n M-K if-shell -F '#{==:#{@ui_binds},on}' \ |
| 116 | "select-pane -D" \ |
| 117 | "send-keys M-K" |
| 118 | |
| 119 | ##### Pane resize ##### |
| 120 | |
| 121 | unbind -n C-M-S-Left |
| 122 | bind -n C-M-S-Left if-shell -F '#{==:#{@ui_binds},on}' \ |
| 123 | "resize-pane -L 5" \ |
| 124 | "send-keys C-M-S-Left" |
| 125 | |
| 126 | unbind -n C-M-S-Right |
| 127 | bind -n C-M-S-Right if-shell -F '#{==:#{@ui_binds},on}' \ |
| 128 | "resize-pane -R 5" \ |
| 129 | "send-keys C-M-S-Right" |
| 130 | |
| 131 | unbind -n C-M-S-Up |
| 132 | bind -n C-M-S-Up if-shell -F '#{==:#{@ui_binds},on}' \ |
| 133 | "resize-pane -U 2" \ |
| 134 | "send-keys C-M-S-Up" |
| 135 | |
| 136 | unbind -n C-M-S-Down |
| 137 | bind -n C-M-S-Down if-shell -F '#{==:#{@ui_binds},on}' \ |
| 138 | "resize-pane -D 2" \ |
| 139 | "send-keys C-M-S-Down" |
| 140 |