Render prompt at the bottom of screen #3872
|
I recently follow this Stack Overflow post to render my prompt at the bottom of the screen. However, when I follow the answer and achieve what I want, I can't seem to render my custom oh-my-posh theme. Here what I tried: function prompt {
# put cursor at the bottom of the buffer
$rawUI = (Get-Host).UI.RawUI
$cp = $rawUI.CursorPosition
$cp.Y = $rawUI.BufferSize.Height - 1
$rawUI.CursorPosition = $cp
Set-PoshPrompt
}This one only renders a function prompt {
# put cursor at the bottom of the buffer
$rawUI = (Get-Host).UI.RawUI
$cp = $rawUI.CursorPosition
$cp.Y = $rawUI.BufferSize.Height - 1
$rawUI.CursorPosition = $cp
# and the prompt itself
oh-my-posh --init --shell pwsh --config E:\tmp\my-custom-theme.json | Invoke-Expression
}renders nothing at first and reset to the original prompt after a command |
Replies: 1 comment 2 replies
|
You're not printing the prompt but interpreting the init script that will override the prompt once again. You want to hijack the prompt function so it will stick at the bottom. Initialize oh-my-posh outside of your custom prompt function, store the value of that function and invoke the original prompt function at the end of your custom function. VSCode does the same for its shell integrations, you can have a look at that here. |

You're not printing the prompt but interpreting the init script that will override the prompt once again.
You want to hijack the prompt function so it will stick at the bottom. Initialize oh-my-posh outside of your custom prompt function, store the value of that function and invoke the original prompt function at the end of your custom function.
VSCode does the same for its shell integrations, you can have a look at that here.