CONTRIBUTING guideWhen I type in a command that e.g. does not exists, the prompt shows only PS> after that until I open a new console window.
This is my $PROFILE:
[ScriptBlock]$Prompt = {
$lastCommandSuccess = $?
$realLASTEXITCODE = $global:LASTEXITCODE
$errorCode = 0
if ($lastCommandSuccess -eq $false) {
#native app exit code
if ($realLASTEXITCODE -is [int] -and $realLASTEXITCODE -gt 0) {
$errorCode = $realLASTEXITCODE
}
else {
$errorCode = 1
}
}
$executionTime = -1
$history = Get-History -ErrorAction Ignore -Count 1
if ($null -ne $history) {
$executionTime = $history.Duration.TotalMilliseconds
}
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
$startInfo.FileName = "C:\tools\oh-my-posh.exe"
$cleanPWD = $PWD.ProviderPath.TrimEnd("\")
$startInfo.Arguments = "-config=""$env:USERPROFILE\.poshthemes\agnoster.omp.json"" -error=$errorCode -pwd=""$cleanPWD"" -execution-time=$executionTime"
$startInfo.Environment["TERM"] = "xterm-256color"
$startInfo.CreateNoWindow = $true
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
$startInfo.RedirectStandardOutput = $true
$startInfo.UseShellExecute = $false
if ($PWD.Provider.Name -eq 'FileSystem') {
$startInfo.WorkingDirectory = $PWD.ProviderPath
}
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $startInfo
$process.Start() | Out-Null
$standardOut = $process.StandardOutput.ReadToEnd()
$process.WaitForExit()
$standardOut
$global:LASTEXITCODE = $realLASTEXITCODE
#remove temp variables
Remove-Variable realLASTEXITCODE -Confirm:$false
Remove-Variable lastCommandSuccess -Confirm:$false
}
Set-Item -Path Function:prompt -Value $Prompt -Force
Expected behavior: See nice prompt again (Even with some form of error sign?)
Actual behavior: Falls back to PS>-prompt
It seems like it fails to run something in the $PROFILE after a failed command, but this is just a guess...
I was wrong about when it happens, it happens even after a successful command.
I did some debugging, $history.Duration.TotalMilliseconds was not set (but $history was for some weird reason, making the cli parameter for oh-my-posh null which led to it not executing. I edited my config so that it ignores the history, now it works.
I don't know whether this is a problem on my system...
I will however take that into consideration and adjust the code to not fail on that.
@firlus what did you change exactly? Maybe I can use your working setup as an example.
I have the exact same result, how can I go about debugging the profile script?
I have the exact same result, how can I go about debugging the profile script?
I will create a small fix for this based on @firlus fix.
@mendoncaftw @firlus I did a quick commit which _could_ fix it, would be great if you can confirm this fixes the issue. Still wonderding why it doesn't have a history with timings, but that's something else.
@JanDeDobbeleer I looked at your PR and changed the script on the profile but I continued to have the default PS> prompt.
I installed through scoop, noticed I didn't have access to any 'Get-PoshThemes' and 'Set-PoshPrompt'. I noticed those functions being defined in the same file next to the profile instructions so I copied that file over to my profile and could access the functions but now obviously don't have the themes and expected folders.
I am going to try and install through Powershell Prerelease stuff.
Correct, Scoop only installs the binaries. Although the setup instructions do explain what to alter when installing with Scoop, if you're not proficient in Powershell and only want to go for a Powershell integration, the module is preferred.
Wow, that was quick, thanks for the help!
Your fix worked, it was basically what I also tried to do to fix the problem.
Thanks for your great tool, I will try to look into creating an own segment since I am trying to learn Go right now and I really love this project!
Well, you also helped me because following all the instructions about Powershell without mixing in scoop also worked for me.
Thank you @JanDeDobbeleer for your help and amazing work. 馃憤馃徎