Reputation: 12446
I don't understand why return doesn't have it's own key when working with the readline of bash.
Using control+m is the same as using return.
How to create two separate keybindings, one for control+m and another function for return?
The same applies to arrow-up/-down etc. . Printing them quoted shows that they are not a seperate key, but a key sequence, so I can not use that sequence for another function.
Upvotes: 0
Views: 50
Reputation: 54505
If you changed that, you would find it cumbersome to use any terminal application, because all of the POSIX-like systems use "newline" for ending lines. An ASCII carriage return ^M
is normally translated into a newline (which happens to be encoded as ASCII line-feed ^J
). If you run stty -a
on your terminal you may notice something like this:
~ (4) stty -a
speed 38400 baud; 40 rows; 80 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
-extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff -ixany -imaxbel -iutf8
-ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;
The icrnl
says that carriage-return is mapped to newline. So... if you break your return
key, you could type control/M or control/J every time you want a newline. Most people prefer just pressing one key for that purpose.
Upvotes: 2