Jonas
Jonas

Reputation: 13

Show multiline PROMPT after clearing terminal Mac OS using zsh

I have made a custom PROMPT that uses multiple lines in my .zshcr file

PROMPT="%(1V.(%1v)"$'\n'".)%F{166}%n%f at %F{229}%m%f in %F{114}%.%f"$'\n'"$ "

but when I clear the terminal using command+K only the last line is shown in the cleared terminal. So I wonder if anyone knows what I need to add to have the full PROMPT shown in the cleared terminal

Upvotes: 1

Views: 736

Answers (2)

Marlon Richert
Marlon Richert

Reputation: 6995

Press CtrlL. This activates Zsh's clear-screen widget.

Upvotes: 2

Blieque
Blieque

Reputation: 675

The terminal emulator isn't aware of where the prompt starts and ends, and so can only offer the scrolling behaviour you experience. I believe the terminal emulator just scrolls the current contents of the window up until the cursor hits the top of the screen, or potentially clears the contents completely.

Running the clear command will get you the result you want. This program performs a similar scrolling operation, then exits and returns control to the shell, which then draws your prompt, just like it does after running any command. I've tested this in Bash, but I think it would apply to Zsh too.

Upvotes: 0

Related Questions