New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error_symbol does not work correctly #3485
Comments
Your error color is different in the screenshot you showed, it's just not red. From examining the GIF, I find that success is #54d995 while error is #56a5a4. What color scheme are you using for Windows Terminal? |
i know it looks weird in the gif, i don't know why but i can assure you it does not change colour, i am using the dracula scheme. |
First I found a temporary workaround (see below for a permanent one): run any commands that explicitly return nonzero error code (e.g. cmd /c "exit -1" or just directly set it to be any nonzero value, like "$LASTCODE = 123123") when you notice the error_symbol fails to work. After that my PowerShell could produce error symbol correctly. It's only temporary because after running anything that set $LASTEXITCODE = 0 (e.g. quit from vim) you need to re-do the above process. The behavior is kind of weird, so I checked the output of "starship init powershell --print-full-init" and it seems that starship uses a prompt function that tries to utilize $LASTEXITCODE when the last command didn't succeed and was an internal PowerShell command. However instead of $global:error[0] it checks $error[0]. It's easy to fix: modify Line 96 of src/init/starship.ps1, add "global:" before "error[0]", then rebuild and install starship (it's a hard-coded variable). |
The current version use $error[0], which is for the module instead of the global status and is always $null, so the $lastExitCodeForPrompot is always $origLastExitCode (see starship#3485 for a related bug). It should be replaced with $global:error[0] Comments are also updated
…3584) * Use global:error[0] for most recent error The current version use $error[0], which is for the module instead of the global status and is always $null, so the $lastExitCodeForPrompot is always $origLastExitCode (see #3485 for a related bug). It should be replaced with $global:error[0] Comments are also updated * fix(pwsh): make Semantic PR bot happy
…tarship#3584) * Use global:error[0] for most recent error The current version use $error[0], which is for the module instead of the global status and is always $null, so the $lastExitCodeForPrompot is always $origLastExitCode (see starship#3485 for a related bug). It should be replaced with $global:error[0] Comments are also updated * fix(pwsh): make Semantic PR bot happy
Bug Report
Current Behavior
After the previous command fals Error_symbol does not change color as per the config file
Expected Behavior
error_symbol should turn red when the previous command fails
Additional context/Screenshots
Further evidence
Possible Solution
Environment
Relevant Shell Configuration
Starship Configuration
The text was updated successfully, but these errors were encountered: