Create custom key tables to group related commands: bind-key -T mytable h previous-window
, then access with bind-key Space switch-client -T mytable
. This creates temporary command modes, similar to vim.
bind-key Space switch-client -T window-ops
Key tables let you create custom "modes" in tmux, similar to vim's command modes. You can group related commands under a single key, then use that key to access a temporary command mode where each key performs a specific function.
# Define a window management table bind-key -T window-ops n new-window bind-key -T window-ops h previous-window bind-key -T window-ops l next-window bind-key -T window-ops r rename-window bind-key -T window-ops q switch-client -T root # Return to normal # Access the table with Ctrl+b w bind-key w switch-client -T window-ops
Create a resize mode that lets you repeatedly resize panes without pressing the prefix key:
# Define resize table that stays active after each command bind-key -T resize-mode h resize-pane -L 2 \; switch-client -T resize-mode bind-key -T resize-mode j resize-pane -D 1 \; switch-client -T resize-mode bind-key -T resize-mode k resize-pane -U 1 \; switch-client -T resize-mode bind-key -T resize-mode l resize-pane -R 2 \; switch-client -T resize-mode bind-key -T resize-mode q switch-client -T root # Enter resize mode with Ctrl+b r bind-key r switch-client -T resize-mode
Show the current key table in your status bar:
# Show current table in status bar set-option -g status-right '#{?client_key_table,[#{client_key_table}],} %H:%M' # Display message when entering modes bind-key w switch-client -T window-ops \; display "Window mode" bind-key r switch-client -T resize-mode \; display "Resize mode"
Always include a q
key in your custom tables that returns to the root table: bind-key -T mytable q switch-client -T root
. This gives you an easy escape route.
A practical window and pane management setup:
# Window operations (Ctrl+b w) bind-key -T window-ops n new-window \; switch-client -T root bind-key -T window-ops h previous-window \; switch-client -T window-ops bind-key -T window-ops l next-window \; switch-client -T window-ops bind-key -T window-ops r rename-window \; switch-client -T root bind-key -T window-ops q switch-client -T root bind-key w switch-client -T window-ops \; display "Window mode" # Show mode in status set-option -g status-right '#{?client_key_table,[#{client_key_table}] ,}%H:%M'