Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to bind a zsh function to the key combo Ctrl+=. I haven't found any working way to do this. If it is possible, I would like to know how.

share|improve this question
up vote 2 down vote accepted

As far as I can tell, the Ctrl+= keybind is not distinguished from the plain = key. While you could bind it, you would also bind to any regular press of equals.

Binding a function to a key is quite easy. You just need to turn the function into a ZSH Widget first. For example:

% function hello_function { echo "hello" }
% zle -N hello_widget hello_function
% bindkey '=' hello_widget

You can find the string to put into bindkey by typing ctrl-v and then your desired keystroke. So I can see that Ctrl+e can be represented as '^E' by typing Ctrl+v Ctrl+e.

Not all modifiers result in a different bindable key, unfortunately.

share|improve this answer
    
Thanks for the answer. It it too bad that it isn't possible to set arbitrary keybindings :( – drewrobb Jan 31 '13 at 20:43
    
There are probably more bindable keys than you think. The control-v trick is quite nifty, but if the key already has a binding then it can interfere with it. You can certainly bind the function keys, and every letter I have tried worked. Maybe try to think of a new nemonic for the action you are trying to perform. – Matthew Franglen Jan 31 '13 at 21:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .