From c5195f6668987f3f2c4461d65a94bf3fa0cdf358 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 20 Jul 2024 23:06:17 +0200 Subject: [PATCH] fix(bash): correctly align multiline prompt relates to #5308 --- src/prompt/rprompt.go | 2 +- website/docs/configuration/block.mdx | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/prompt/rprompt.go b/src/prompt/rprompt.go index a48692fa..66312ceb 100644 --- a/src/prompt/rprompt.go +++ b/src/prompt/rprompt.go @@ -61,7 +61,7 @@ func (e *Engine) RPrompt() string { // bash prints this on the same line as the prompt so we need to move the cursor down // in case the prompt spans multiple lines if lineCount > 0 { - return terminal.SaveCursorPosition() + strings.Repeat("\n", lineCount) + text + terminal.RestoreCursorPosition() + return terminal.SaveCursorPosition() + fmt.Sprintf("\x1b[%bB", lineCount) + text + terminal.RestoreCursorPosition() } return text diff --git a/website/docs/configuration/block.mdx b/website/docs/configuration/block.mdx index b160398d..9b7cbcc9 100644 --- a/website/docs/configuration/block.mdx +++ b/website/docs/configuration/block.mdx @@ -43,6 +43,12 @@ Tells the engine what to do with the block. There are two options: - `rprompt` renders one or more segments aligned to the right of the cursor. Only one `rprompt` block is permitted. Supported on zsh, bash, PowerShell, cmd, nu and fish. +:::warning bash +`rprompt` is not natively supported in bash and comes with one side effect. When you have a multiline prompt, +the `rprompt` will not display when your new prompt is drawn at the bottom of the terminal. This is a limitation +of bash and not Oh My Posh. +::: + ### Newline Start the block on a new line - defaults to `false`. For `pwsh` and `cmd` this will not print a newline