Created
November 2, 2020 00:26
-
-
Save palcodes/532de46a0487c6ff219bcc560ee47d9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ScriptBlock]$Prompt = { | |
$realLASTEXITCODE = $global:LASTEXITCODE | |
if ($realLASTEXITCODE -isnot [int]) { | |
$realLASTEXITCODE = 0 | |
} | |
$startInfo = New-Object System.Diagnostics.ProcessStartInfo | |
$startInfo.FileName = "C:\tools\oh-my-posh.exe" | |
$config = $global:PoshSettings.Theme | |
$cleanPWD = $PWD.ToString().TrimEnd("\") | |
$startInfo.Arguments = "-config=""C:\Users\{username}\Documents\paradox.json"" -error=$realLASTEXITCODE -pwd=""$cleanPWD""" | |
$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-Variable realLASTEXITCODE -Confirm:$false | |
} | |
Set-Item -Path Function:prompt -Value $Prompt -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment