2

I was wondering if there is an easy way to configure ZSH (I am using oh-my-zsh) and/or FISH (just started fiddling with this) to not keep the cursor/promt at the bottom of the terminal as soon an the buffer exceeds the number of displayable lines but rather at the middle of the screen.

The reason for this is that I keep staring at the bottom of my screen when navigating in the console but working mostly in the middle of the terminal when for example doing work in VIM. I would like to try such a behavior to see if that.

2
  • I guess I'm confused about how that might work. Let's say you start from the vertical center'ish of the screen and run a command like ls -la /bin. The results are going to scroll off the screen. Do you want the entire bottom of the terminal to be blank, and the prompt back in the vertical center after that? Or are you saying that you want the prompt to overwrite the results? Apr 10, 2022 at 22:22
  • I want (to try) to have the bottom of the terminal blank. Just as an experiment for now. For other applications than the shell (such as VI, a pager, ...) I want to use the whole space. But staring at the bottom of a shell the whole time feels a bit counter intuitive. Maybe that's just me.
    – sontags
    Apr 11, 2022 at 5:15

1 Answer 1

3

A quick trial shows this seems to work in ZSH:

PS1=$'\n\n\n\n\n\n\n\n\e[8A'"$PS1"

This has the prompt print 8 newlines, then moves the cursor back up 8 lines with the \e[8A escape code, before printing the actual prompt.

You can add more newlines and increase the scroll-up to match, depending how far off the bottom you want to be.

2
  • This worked for me! Thanks. Having the prompt at the bottom hurts my neck. How can i move the cursor back up 16 lines such that it appears more in the middle. 8 lines is still quite below for a large screen.
    – A. K.
    Aug 15, 2022 at 4:59
  • 1
    Just put 16 \n instead of 8, and change the 8 to a 16. Aug 15, 2022 at 19:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .