From a6e90a6bd69318341bd0e4d3cf71d1cc5c4e1f34 Mon Sep 17 00:00:00 2001 From: Kutsan Kaplan Date: Wed, 2 Oct 2024 19:52:11 +0300 Subject: [PATCH] feat(zsh): make retain initial new line of pure prompt --- .config/zsh/config/prompt.zsh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.config/zsh/config/prompt.zsh b/.config/zsh/config/prompt.zsh index 5243b1a6..abf0cdee 100644 --- a/.config/zsh/config/prompt.zsh +++ b/.config/zsh/config/prompt.zsh @@ -18,3 +18,18 @@ prompt pure # Prompt styles. zstyle :prompt:pure:prompt:error color 1 zstyle :prompt:pure:prompt:success color 15 + +# This clear screen widget allows Pure to re-render with its initial +# newline by manually clearing the screen and placing the cursor on +# line 4 so that the prompt is redisplayed on lines 2 and 3. +custom_prompt_pure_clear_screen() { + # Enable output to terminal. + zle -I + + # Clear screen and move cursor to (4, 0). + print -n '\e[2J\e[4;0H' + + # Redraw prompt. + zle .redisplay +} +zle -N clear-screen custom_prompt_pure_clear_screen