JanDeDobbeleer / oh-my-posh2

A prompt theming engine for Powershell
MIT License
5.18k stars 281 forks source link

Add Options.PreserveLastExitCode #307

Closed gregmac closed 3 years ago

gregmac commented 3 years ago

This adds to #289 by adding an option to disable the feature, in case a theme is already handling this in some way.


In my custom theme, I was already doing this, but with two additional features:

Displaying the code is very helpful, but the trouble is if you run a powershell cmdlet, LASTEXITCODE doesn't get reset. This means the prompt will constantly show a non-zero exit code (displayed as a red error, in my prompt) until you run a successful executable command.

Unfortunately, clearing LASTEXITCODE is kind of non-standard behaviour so I'd guess it's not good to do this as part of oh-my-posh.