This is sort of a sideways answer to your question, but I prefer using an inverted prompt (which stands out and is easy to spot) for just the purpose of quickly being able to determine where in the scrollback the last command was run.
You can invert your prompt's color (i.e. black text on white background) by adding the ANSI sequences <esc>[7m
(invert) to the beginning of the prompt, and <esc>[0m
(reset) to the end of it.
Most, more fancy shells (like bash
and zsh
) also keep track of the length of the prompt on screen, so you'll need to add some sugar to tell the shell that these sequences do not move the cursor forward. In zsh
this is done using %{...%}
while bash
uses \[...\]
.
Thus, to invert your prompt in zsh
use:
PROMPT=$'%{\e[7m%}'"${PROMPT% }"$'%{\e[0m%} '
and in bash
, use:
PS1=$'\[\e[7m%\]'"${PS1% }"$'\[\e[0m\] '
$'...'
is a special way of quoting a string, which will translate \e
into <esc>
${VARNAME%SUFFIX}
removes outputs VARNAME
, but strips off any ending string SUFFIX
(in the above cases the final space, since we don't want to invert that in order to see the cursor properly).
Occasionally I find that the above trick is impractical (typically when the need arise to look at some logfile or something on a server which isn't really mine to customize to death), but on those occasions I usually find that all of the above suggested solutions are also too much of an effort, and I just press <enter>
for a bit.
reset
alias space='for lines in {1..10}; do echo; done'
. Then callspace
from the terminal to get 10 blank lines.bash
:bind '"\e[24~":"\n\n\n\n\n"'
and press F12.alias _l=$'\n\n\n\n\n'
and then do<ESC>@l
and it will enter 5 newlines for you. They can also be used recursively - and can even swap command/edit modes w/<ESC>
.