-1

I have the following line in my .inputrc which does not appear to be working:

"\C-/": insert-comment

When I press C-/ I expect the current line to be prefixed with the comment character (#) and executed, but when I press it nothing happens.

If I change the keymapping to something like \C-t then it works fine.

Why can't I use C-/ as a keymapping?

2

The readline library follows the model of a physical terminal that could only transmit ASCII control characters and ANSI escape sequences. C-/ is not an ASCII control character; the ASCII control characters are c-@, C-a .. C-z, C-[, C-\, C-], C-^, C-_.

  • So what does this mean for Meta sequences like M-#? Or are they not subject to the same restrictions? – DanielGibbs Nov 3 '17 at 7:49
  • Meta-# is by convention an escape control character followed by # (or whatever character you want to "metafy"). The Readline library can also be configured to interpret the eight bit, if set, as a meta flag if the terminal (emulator) supports this. But this is very esoteric, since it restricts the input character set to seven bits. – Johan Myréen Nov 3 '17 at 8:10
  • Are there limitations on which characters can be "metafied"? M-/ doesn't seem to work for me either. – DanielGibbs Nov 3 '17 at 9:11
  • For some reason I can't get the syntax "\M-/" to work in .inputrc either, but "\e/": "your action here" works. In my terminal emulator combining the Alt key with almost any key prepends an Esc to the key character. You can check by pressing Ctrl-v before the Alt-key combination, this prints the output like this: ^[/ (Alt-/ used as an example). – Johan Myréen Nov 3 '17 at 15:28

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.