Put the following into a file:
command1()
{
if [ "$BASH_COMMAND" != command2 ]
then
command_flag=1
fi
return 0
}
trap command1 debug
command2()
{
if [ "$command_flag" ]
then
echo ""
fi
command_flag=
}
PROMPT_COMMAND=command2
I advise you to change the names command1
, command2
, and command_flag
to values that you’re not likely to type. Then source
that file.
(Or just put the above into your .bashrc
.)
The trap command1 debug
command causes the command1
function to be called
any time you type a command. The command1
function
sets the command_flag
flag to indicate that there was a command.
(The command1
function is not called when you just hit Enter.)
PROMPT_COMMAND=command2
causes the command2
function to be called
whenever the shell is about to issue a PS1
prompt.
The command2
function checks the command_flag
flag
to see whether you typed a command or just Enter.
If you typed a command, command_flag
will be set
and command2
will write a blank line to the screen.
(If you figure out how to create a vertical space that’s a fraction of a line,
change the echo
command.)
If you just hit Enter, command_flag
will not be set.
Then clear the flag so the next prompt will be done correctly.
Note that the command1
function is called
when the shell runs the command2
function;
therefore, command1
needs to make it a special case
(it doesn’t count as a command).
\E#3
thru\E#6
- double/single-height/width line top/bottom modes. And they're not alone.