Does anyone know how to bind function keys in zsh? I want to be able to use function keys in programs running in my terminal, not bind them to some function in zsh. I've tried putting bindkey "\e[OP" key_f1 in .zshrc but I get No such widget `key_f1' when I try that. Suggestions?

  • I doubt, that zsh is to blame (see my answer), so perhaps you should include in your question, what terminal you use and what program isn't working correctly. – mpy May 10 '13 at 15:19

To explicitly assign a key to itself use

bindkey "\e[OP" self-insert

To unbound a key, use

bindkey -r "\e[OP"

To get the symbols for a specific key you can simply use cat: So cat Enter F1 produces in my terminal (URxVT) the following string: ^[OP. This can vary depending on the terminal, especially for combinations like Ctrl+

But concerning your specific problem: I doubt, that zsh is the reason that the functions key do not work in your program, because when the program is running, zsh should not capture any keys. I think it's more probably, that the program itself does not understand the symbols the terminal sends to it. So, you could try another terminal (xterm worked in most such cases for me). If that failes to, you probably have to check the keyboard mapping of the X server (~/.Xmodmap in Linux, I unfortunately don't where to tune OSX...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.