Normally, whenever one is typing up a compound command at the command prompt of a terminal — such as a…
for var in ... ; do ... ; done
… iteration — and one presses the keyboard shortcut sequence Ctrl+XCtrl+E, the default editor should be loaded with that compound command in it, the various sections of the command neatly ordered as if they are the multiple lines of a shell script.
One can then edit this “script”, and without saving it, exit the editor by way of the usual keyboard shortcut or menu entry, and then the “script” will be neatly displayed as a properly formatted single-line command again at the prompt.
This works regardless of whether one is typing the command at the prompt of a terminal emulator in a graphical environment, or whether one is logged in at a character-mode virtual console — i.e. a tty
.
The editor that will be invoked is the one defined via the ${EDITOR}
variable, and if this variable has not been set, then the shell will attempt to invoke one of the usual suspects, be it emacs
, vi
or nano
.
Now, I have all three of the editors above installed, and I do have the ${EDITOR}
variable set to /usr/bin/nano
.
[nx-74205:/dev/pts/3][/home/aragorn]
[aragorn] > for program in nano emacs vi ; do type $program ; done
nano is /usr/bin/nano
emacs is /usr/bin/emacs
vi is /usr/bin/vi
[nx-74205:/dev/pts/3][/home/aragorn]
[aragorn] > echo $EDITOR
/usr/bin/nano
[nx-74205:/dev/pts/3][/home/aragorn]
[aragorn] >
However — and I’m not sure on when this changed because I don’t use this functionality all that much, given that I’m fairly good at getting my compound commands right without this aid, but — apparently the Ctrl+XCtrl+E sequence no longer works.
From the looks of things, Ctrl+X is still recognized as the terminal escape character, but the Ctrl+E character — which, when used all on its own without the preceding Ctrl+X, correctly moves the cursor to the end of the line — now appears to send a carriage return to the terminal instead, resulting in whatever you were typing to get passed onto the shell as a command.
Yet, the terminal options suggest that everything should still work as before…
[nx-74205:/dev/pts/3][/home/aragorn]
[aragorn] > bind -P | grep edit
edit-and-execute-command can be found on "\C-x\C-e".
emacs-editing-mode is not bound to any keys
vi-edit-and-execute-command is not bound to any keys
vi-editing-mode is not bound to any keys
[nx-74205:/dev/pts/3][/home/aragorn]
[aragorn] >
Is this a bug, or has anything changed upstream to the bash
or terminal configuration in recent times?