Depends what exactly you want to do.
terminals have two major modes both of which can be fine tuned with extra settings:
- cooked/canonical mode. In that mode, the terminal comes with an internal line editor where the
\) characters can be used to edit the line. Nothing is sent to the application reading from the terminal device until the
^J character is received.
- raw mode. Where every character is available for reading to the application reading the terminal device as soon as it is typed, or after a delay or after so many have been entered depending on the time and min parameters, but in anycase, not with that internal line editor.
In both cases, the
^M (CR) character can be automatically translated to
^J (LF) (or ignored for those terminals that send both CR and LF upon pressing Enter).
The first mode is the default mode of the terminal. The second mode is used by applications like
vi that want to take control of the line editing.
In the first mode, you cannot change what character is used to accept the line.
But you may be able to tell your terminal to send the
^J character upon pressing this or that key. For instance, with
xterm, you can use the
translations X11 resource to change the key mapping and tell it to send whatever you want upon a given key press. If your terminal doesn't support remapping the keyboard, you can still use GNU
screen to do the translation for you. For instance, if your terminal sends the
^[OP character sequence upon pressing F1, you can add
bindkey \033OP "\012"
~/screenrc to tell it to send LF when you press F1
For the second case, that is where applications take control of the input, you can still use the same approach as above, but you could also configure each individual application to do this and that when you press F1
For instance, with
zsh, the LF character is bound to the
zsh widget. You could do:
bindkey "^[OA" accept-line
to have F1 bind to that same widget.
Note that Ctrl+Space usually sends the NUL character which you can refer to as