3

I use Meta-ijkl as arrows in Emacs, and M-; as a backspace, so I want to make the keys in bash represent the same style. Moving and deleting works well, but for some reason I cannot bind unix-line-discard to C-; that would erase the whole line from the cursor to the beginning into the kill buffer. Since default emacs keys for copy, kill and yank are C-j, C-k and C-y, another C- combination fits there quite well. And \e: (Meta-Shift-;) is already bound to backward-kill-word. C-u that does unix-line-discard by default, works fine, but it’s inconvenient to press. If I rebind this function to, say, \C-g, it works fine, too.

In the ~/.inputrc I have

"\C-;": unix-line-discard

I’ve also tried

"\C-\;": unix-line-discard
"\C-\x3b": unix-line-discard

with no effect. C-v C-; in the shell doesn’t print anything except for the usual semicolon, and \C-; with all its variants only prints it, too, and nothing more.

I work in Urxvt.

5
  • Your terminal is probably only able to generate control codes of the chars with code values 0x40 to 0x5f, which doesnt include ;.
    – meuh
    Mar 3, 2016 at 18:07
  • 1
    Not possible with configuring readline alone. Which terminal are you using? stackoverflow.com/a/9941824/1213041
    – cdosborn
    Mar 3, 2016 at 19:31
  • @cdosborn urxvt.
    – tijagi
    Mar 3, 2016 at 19:40
  • Try the suggestion of this answer.
    – cdosborn
    Mar 3, 2016 at 19:45
  • @cdosborn no luck with \C-\x1b or \C-[1;2P.
    – tijagi
    Mar 3, 2016 at 19:59

1 Answer 1

6

Agreeing with the comment by @meuh, terminals don't generate a distinct code for control; (normally).

The link suggested by @tijagi is for xterm and does not apply to urxvt. Using the manual page for urxvt shows that you can start here:

   keysym.sym: string
       Compile frills: Associate string with keysym sym. The intervening
       resource name keysym. cannot be omitted.

and use a setting like one of these:

*keysym.Control-semicolon: mybinding
URxvt.keysym.Control-semicolon: mybinding

using the class name as necessary to override existing resources, and where mybinding is whatever you care to have urxvt send when you type control; (but read the manual page to get the syntax right). @meuh suggests using \025 (^U) since that is normally bound to unix-line-discard.

Further reading:

1
  • The actual line to put in your resources (eg .Xdefaults) is URxvt.keysym.Control-semicolon: \025 or you can just try it out with the command urxvt -xrm 'URxvt.keysym.Control-semicolon: \025' The 025 is the octal code for Control-U which is the default binding for bash's unix-line-discard.
    – meuh
    Mar 5, 2016 at 8:31

You must log in to answer this question.

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