The line
"\M-[3~": delete-char
is incorrect because it tells bash to look for the meta character for [
, which (according to bash) could be the escape character followed by [
, or it could be the character formed by OR'ing [
with 0x80, i.e., 0xdb which is Û
The actual key would use just the escape character, so you should use this setting:
"\e[3~": delete-char
If using bash
, the following should do the trick:
TOLASTLINE=$(tput cup "$LINES")
PS1="\[$TOLASTLINE\]$PS1"
Or (less efficient as it runs one tput
command before each prompt, but works after the terminal window has been resized):
PS1='\[$(tput cup "$LINES")\]'$PS1
To prevent tput
from changing the exit code, you can explicitly save and reset it:
PS1='\[$(retval=$?;tput cup "$LINES";exit $retval)\]'$PS1
Note that the variable retval
is local; it doesn't affect any retval
variable you might have defined otherwise in the shell.
Since most terminals cup
capability is the same \e[y;xH
, you could also hardcode it:
PS1='\[\e[$LINES;1H\]'$PS1
If you want it to be safe against later resetting of PS1, you can also utilize the PROMPT_COMMAND
variable. If set, it is run as command before the prompt is output. So the effect can also be achieved by
PROMPT_COMMAND='(retval=$?;tput cup "$LINES";exit $retval)'
Of course, while resetting PS1
won't affect this, some other software might also change PROMPT_COMMAND
.
Best Answer
Try Shift+Page down or something similar (eg. Ctrl+Alt+Page down).
Page down sends the page down key to the program running inside the terminal. If that's your shell (bash/zsh/whatever), it probably doesn't accept the key combination, and ends up trying to parse the encoded key, which contains
~
.It's more likely you were scrolling in your terminal program itself, using the scroll bar or something similar, so you want a key that your terminal program accepts directly. You didn't specify which program you're using, but Shift+Page down is common. You can also try different modifier key combinations; your terminal's key binding setup might also have more information.