2

There is way to bind Control+apostophe via bindkey?
I have tried:

 bindkey "\C-'"
 bindkey "^'"
 bindkey "\C-\x27"

and all of this is not working

3

Probably not. At least not without modifying your terminal too.

A shell runs on a terminal. The basic unit of input on a terminal is a character, not a keypress. When you add a key binding to your shell, you're really binding a character sequence, not a key combination. There is no Ctrl-apostrophe character.

Ever since the earliest ASCII-based terminals, there has been a set of keys that can be combined with Ctrl to produce a single character. The keys that do this correspond to ASCII codes 0x3f through 0x5f: ? @ A-Z [ \ ] ^ _

When the Ctrl key is pressed with one of those characters, the value is transmitted with the 0x40 bit inverted. 0x3f ? becomes 0x7f DEL, and the rest become 0x00 through 0x1f. Apostrophe is 0x27, so if it was combined with the Ctrl key by this rule, it would become 0x67, which is g. Getting a g when you type Ctrl-apostrophe wouldn't be useful, so the terminal doesn't do that.

However, it is possible to bind keys that don't correspond to single ASCII characters, like the arrow keys for example. This works because those keys are translated by the terminal into an escape sequence - a sequence of characters starting with escape. These sequences can be bound to useful actions. For example, ESC [ A is normally the up arrow key, which is bound to a history-related action in the shell.

If you're determined enough, you can convince your terminal to output some escape sequence for Ctrl-apostrophe, and then use that escape sequence in your bindkey command. To continue along those lines, consult the documentation for your terminal.

1
  • 2
    Thanks. In urxvt it can be done by adding "URxvt.keysym.C-apostrophe: *new keysum*" in $HOME/.Xresourses – asdfffiii Jun 6 '14 at 13:29

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.