I don't think this is possible in bash
. However, a reasonable subset of the functionality of the prompt can be simulated in bash
4 or later by using the read
builtin and immediately executing the input with eval
:
$ read -ei "ls -l"; eval "$REPLY"
Implicit line continuation is not available, such as if you end the line with a |
; you'll need to explicitly provide the line-continuation character, and the next line will also have the initial text inserted, so you'd have to clear the line before continuing.