Ctrl+Alt+e expands command substitutions ($()
and ``
). It also replaces other kinds of expressions in your command prompt, e.g. aliases, see resources below for more details.
In my experience it is a very useful and little known feature of Bash.
You can use ``
and Ctrl+Alt+e to replace a command line with its output. It doesn't preserve newlines, though. Also be careful with the side effects of anything you expand on your command line prompt. If you expand an `rm filename`
, it will remove filename
when you use Ctrl+Alt+e.
Example:
$ `perl -E'say "hi"; say "more lines";'`
Ctrl+Alt+e
$ hi more lines
If the shortcut doesn't work for you, try Esc, then Ctrl+e. It has the same effect. You have to do it this way e.g. in the default Mac terminal.
Resources: