In my .bashrc file I'm trying to bind a custom escape-sequence key to a control-sequence.
What I have is:
bind -x '"\eJD0C": "^C"'
And it does not execute the shell control-sequence ^C which cancels the execution of a process.

So is there a way to do this?
Or is it not possible?
If not possible, what alternatives should I look into?

  • 1
    It does work, but it seems unlikely that what it does is what you wanted. You can edit your question to say what you're trying to achieve. – Michael Homer Apr 14 '18 at 1:02
  • Just edited it. – John DeBord Apr 14 '18 at 1:21
  • Which escape sequence are you trying to create, as in, which exact key sequence are you expecting to cancel the execution of the process? Also, what is the purpose of rebinding this? Is Ctrl-c not working as expected? – l0b0 Apr 14 '18 at 2:47

That is not a shell control sequence.

It is a special character, recognized by the line discipline when it is in canonical input mode.

Three things militate against you:

  • The line discipline is not in canonical mode when the Bourne Again shell is using the GNU Readline library to read lines of input interactively. It is in non-canonical mode, and all special character recognition by the line discipline is turned off.
  • The GNU Readline library is not responsible for input when the Bourne Again shell is doing something other than reading a line of input interactively, and mappings set up for the Readline library are irrelevant at those points. When you enter the special character whilst the shell is waiting for a child process to terminate, this is handled by the line discipline.
  • The line discipline can only recognize single characters as special, not sequences of multiple characters that terminals use for encoding editing and function keys. The terminal API for setting special characters only works in terms of single characters.

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.