Keeping the prompt on last line: doing it better?
For personal preference (better consistency on where to look for to find the prompt and output from previous command, also after clearing the screen) I like to have the prompt at the bottom line since the beginning of the session, instead of having it at the top.
The way I implemented this consists of defining a clear2
function:
clear2() { echo -e '\033[2J\033['$LINES';0H' }
which clears the screen and places the cursor on the last line.
I can also bind it to CTRL+L (at least on zsh) with:
clear2w() { clear2; zle redisplay }
zle -N clear2w
bindkey '^L' clear2w
# optional for vi keymap:
bindkey -M vicmd '^L' clear2w
bindkey -M viins '^L' clear2w
It looks pretty nice. The only drawback happens if I resize (e.g. go fullscreen) the window and the content is less than a screen page. In that case the prompt would end up in the middle of screen.
How about having iTerm2 natively support this visualization mode? I.e. content would be anchored at bottom of the screen and not at the top? That would not require ANSI sequences hacks, and it would work also when the window is resized.
I can attach screenshots if needed, but I think the issue is clear enough.