Resolved. Thank you @Compo for your observations. I discarded the .bat script approach. Final solution, I create an event in the .ps1 profile, that run every time a command (besides itself) runs, calculate the current window wide and save it in a global variable accessible from the omp.json theme file. Here is the code:
oh-my-posh init pwsh --config 'D:\repos\zsh-pwsh-wt\windows-pws-posh\kalimod.omp.json' | Invoke-Expression
$width = [console]::WindowWidth
$result = "ˍ" * ($width-1)
[System.Environment]::SetEnvironmentVariable("PROMPT_LINE", $result, [System.EnvironmentVariableTarget]::Process)
Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -Action {
$width = [console]::WindowWidth
$result = "ˍ" * ($width-1)
[System.Environment]::SetEnvironmentVariable("PROMPT_LINE", $result, [System.EnvironmentVariableTarget]::Process)
oh-my-posh init pwsh --config 'D:\repos\zsh-pwsh-wt\windows-pws-posh\kalimod.omp.json' | Invoke-Expression
}
And here is the block and how I call it in the theme:
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "command",
"style": "plain",
"foreground": "#ffffff",
"properties": {
"shell": "powershell",
"command": "$env:PROMPT_LINE"
}
}
]
},