Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Prompt at the bottom of the terminal window? #563

Closed
bwoodruff opened this issue Mar 14, 2020 · 15 comments
Closed

[Question] Prompt at the bottom of the terminal window? #563

bwoodruff opened this issue Mar 14, 2020 · 15 comments

Comments

@bwoodruff
Copy link

I noticed in a number of your screen recordings where transient prompt is enabled you've got the prompt at the bottom of the terminal window.

e.g. https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/performance.gif

Is this just a visual trick with the recording, or do you really have a way to have GNOME terminal start with the prompt at the bottom of the window? If the latter, would you mind sharing?

Thanks for building such a useful and enjoyable tool.

@Aloxaf
Copy link

Aloxaf commented Mar 14, 2020

or do you really have a way to have GNOME terminal start with the prompt at the bottom of the window

put this line in your zshrc, before load instant prompt.

printf '\n%.0s' {1..100}

@romkatv
Copy link
Owner

romkatv commented Mar 14, 2020

put this line in your zshrc, before load instant prompt.

Yes, that's pretty much how I've recorded this. You can even see cursor in the top-left corner on the first frame of the gif.

I found that for users who aren't familiar with transient prompt it's much easier to follow what's going on when prompt is at the bottom. After you use transient prompt for a little while, it becomes natural regardless of prompt position.

@romkatv romkatv closed this as completed Mar 14, 2020
@ForestBeaver
Copy link

To bump a closed issue; I think this would be a good configuration option. When I saw the gif for transient prompts I expected (and was hoping) it would push the input to the bottom.

@romkatv
Copy link
Owner

romkatv commented Apr 8, 2020

It's easy to push cursor to the bottom of the screen when you start zsh. The problem is that it can be pushed up by zle, zle widgets and external commands. When this happens, there is no way to push it back down without filling (a portion of) screen with empty space. This feature could be implemented in a terminal but not on the level of applications running in the terminal.

@nfbyte
Copy link

nfbyte commented Jul 10, 2020

When using xterm with these lines in .zshrc (set before powerlevel10k, which is configured with sparse lines, instant prompt and transient prompt),

# Change cursor to I-beam
printf '\033[5 q\r'

# Move prompt to the bottom
printf '\n%.0s' {1..100}

the prompt appears at shell startup like so:

.
.
.
.
.
.
.~/my-prompt
.❯ |
.

but after using a command, it shifts to the bottommost line like so:

.
.
.
.❯ echo 123
.123
.
.~/my-prompt
.❯ |

Would it be possible to fix this inconsistency (i.e. have the prompt either always have an empty line under it or always show on the bottommost line - ideally the former)?

@romkatv
Copy link
Owner

romkatv commented Jul 10, 2020

Would it be possible to fix this inconsistency (i.e. have the prompt either always have an empty line under it

This is impossible without patching the source code of your terminal emulator.

or always show on the bottommost line

You can do this by adding the following parameter to ~/.p10k.zsh:

typeset -g POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES=0

It doesn't matter where exactly in ~/.p10k.zsh you add it. Next to the existing POWERLEVEL9K_INSTANT_PROMPT would be sensible.

Once you add the parameter, restart zsh (e.g., with exec zsh) twice.

@t-dub
Copy link

t-dub commented Mar 17, 2023

Rather than choosing an arbitrarily high number of blank lines to print, you can use the actual height of the terminal which is (usually) set in the environment variable $LINES. So then the line in your .zshrc becomes:

printf '\n%.0s' {1..$LINES}

Note that this should be placed in your .zshrc before the p10k instant prompt. It runs fast enough to not negate the benefits of the instant prompt and will ensure you don't get "judder" with your heavily decorated p10k prompt showing at the top of the terminal (however briefly) before jumping to the bottom.

@romkatv
Copy link
Owner

romkatv commented Mar 17, 2023

FWIW, zsh4humans can put cursor at the bottom of the terminal and keep it there. You can see how it works in this screencast:

asciicast

@ajay007e
Copy link

Rather than choosing an arbitrarily high number of blank lines to print, you can use the actual height of the terminal which is (usually) set in the environment variable $LINES. So then the line in your .zshrc becomes:

printf '\n%.0s' {1..$LINES}

Note that this should be placed in your .zshrc before the p10k instant prompt. It runs fast enough to not negate the benefits of the instant prompt and will ensure you don't get "judder" with your heavily decorated p10k prompt showing at the top of the terminal (however briefly) before jumping to the bottom.

But it goes up when we use clear ??
So do you guys have any hack to solve this issue ?

@romkatv
Copy link
Owner

romkatv commented Sep 22, 2023

If you are using zsh4humans, see https://github.com/romkatv/zsh4humans/blob/master/tips.md#prompt-at-bottom

If not, improvise.

@ajay007e
Copy link

No, I am not using zsh4humans. I am using the typewriter theme.

@romkatv
Copy link
Owner

romkatv commented Sep 22, 2023

Then improvise.

@Aqa-Ib
Copy link

Aqa-Ib commented Oct 2, 2023

But it goes up when we use clear ?? So do you guys have any hack to solve this issue ?

alias clear="clear && printf '\n%.0s' {1..$LINES}"

@rwmitchell
Copy link

rwmitchell commented Oct 2, 2023

printf "\e[H\ec\e[${LINES}B"

This avoids printing a bunch of newlines and also does the 'clear'

@fuchsg
Copy link

fuchsg commented Nov 6, 2023

You could also use something like:

clear && tput cup $LINES 0

And to make sure the prompt stays down after using something like fzf, I have this in my zsh hooks:

function bottom_prompt {
  tput cup $(($LINES-2)) 0
}
add-zsh-hook precmd bottom_prompt

The $(($LINES-2)) statement is just to avoid scrolling with my multiline prompt. Depending on your prompt design you might have to adjust that number to avoid unnecessary scrolling in one direction or overwriting some output in the other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants