This is very possible. If your bash has C-v
set as the readline quoted-insert command, you can simply add the following to your ~/.inputrc
:
RETURN: "\C-v\n\C-v\n\n"
This wil make bash (readline, actually) insert two verbatim newlines before a regular interpreted newline. By default, only one is inserted, which is what causes output to start on the line after the prompt.
You can test if C-v
is set to quoted-insert by typing it in bash (that's Ctrl+V
) followed by e.g. an up arrow. This should print ^[[A
or something similar. If it doesn't, you can bind it in ~/.inputrc
too:
C-v: quoted-insert
RETURN: "\C-v\n\C-v\n\n"
~/.inputrc
can be created if it doesn't exist. The changes will not take effect in running bashes unless you issue a readline re-read-init-file command (by default on C-x C-r
). Be careful though. If you do something wrong, enter will no longer issue commands, and fixing your mistake could prove to be difficult. If you should do something wrong, C-o
will by default also accept the line.
Adding a newline followed by moving the cursor back to the regular prompt (like you described) is possible, but will not have the effect you intend. The newline you inserted would simply be overwritten by the application output, since you moved the cursor back in front of it.