0

Does exist the way, binding line continuation action to specific key in the bash?

That is, instead pressing two keys \ and Enter, one after another, press two keys simultaneously, for example Alt + Enter.

Instead this:
$ echo one \Enter
> two \Enter

Do this:
$ echo one, then press Alt + Enter = get backslash and newline
> twoAlt + Enter - get backslash and newline, etc.

I have looked at readline binding and doesn't find such action.Would not say, that this functionality needed me so much :), just interesting.

1

You can do something like that using bind command

bind '"\e[24~":"\\\n"'

I use F12 because i don't know how to bind C-^M i think its impossible bcos enter is C-M but you can use:

bind '"\C-m":"\\\n"'
  • Thanks, though I found the same solution itself 10 minutes ago, your answer pointed me that binding to C-m broke Enter key :) But I added Alt key to my combination and now, it work how I was wanted. Either Alt + Enter or Ctrl + Alt + m doing the line continuation. – MiniMax Jun 9 '17 at 14:21
0

I found answer in the Arch Linux wiki - it can be done by macros:

bind '"\e\C-m":" \\\C-j"'

It bind the needed functionality to the Alt+Enter or Alt+Ctrl+m combination.

Then it needed to add this line to the .bashrc file and this binding will work after reboot.

To look at your available macros, run bind -s:

$ bind -s
$ "\e\C-m": " \\\C-j"

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.