tmux-modal icon indicating copy to clipboard operation
tmux-modal copied to clipboard

Can't bind `/` in keybindings.conf

Open slacksystem opened this issue 1 year ago • 1 comments

Hi,

I have added the following to my .tmux.conf:

set -g @modal-keybindings-conf ~/.tmux/conf/keybindings.conf
set -g @modal-commands-conf ~/.tmux/conf/commands.conf

in ~/.tmux/conf/keybindings.conf, in addition to the defaults, I have added

## Rename window.
KBD_WIN_RENAME=,

## Search within windows, only visible part, ignores case.
KBD_WIN_SEARCH='/'

##q Pane command prefix (same bindings as KBD_WIN but without the prefix).

and in ~/.tmux/conf/commands.conf

## Rename window.
CMD_WIN_RENAME='command-prompt -I "#W" "rename-window -- \"%%\""'

## Search within windows, only visible part, ignores case.
CMD_WIN_SEARCH='tmux command-prompt -p "Search for:" "find-window -Zi  %%"'

## Split command prefix.

(context included to indicate position)

I've tried both / and '/' as the values for KBD_WIN_SEARCH and neither seem to be bound. They don't do anything and list-keys doesn't have an entry for them. I've installed using tpm and when I add bind -T ktm-window '/' command-prompt -p "Search for:" "find-window -Zi %%" below run '~/.tmux/plugins/tpm/tpm' the keybind works, so there's a workaroubut otherwise it doesn't. I would think that any key that works with tmux bind-key should work in the config file. Any ideas why this isn't working?

slacksystem avatar May 08 '24 20:05 slacksystem

Adding new commands are unfortunately not supported. Only the ones already specified in commands.conf can be customized.

However, adding support for custom commands is maybe something we should add. I guess many would want this (and maybe bind stuff from other plugins). That's actually a really good idea!

Just designing it quickly on top of my head, I'm thinking we should have a "template" CMD_$KT_CUSTOM_*, where $KT is an existing key table. Users can then add whatever they want, e.g. in your case

CMD_WIN_CUSTOM_SEARCH='tmux command-prompt -p "Search for:" "find-window -Zi  %%"'

and correspondingly

KBD_WIN_CUSTOM_SEARCH='/'

This way we can identify and separate custom commands and their keybindings. Thanks for the idea! I'll see if I have time to cook something up this week.

whame avatar May 09 '24 22:05 whame