diff --git a/.gitignore b/.gitignore index 6b984ef7..ff43f2f0 100644 --- a/.gitignore +++ b/.gitignore @@ -241,3 +241,5 @@ $RECYCLE.BIN/ cosign.key *.omp.json.bak + +__debug_bin diff --git a/.vscode/launch.json b/.vscode/launch.json index bfe5c199..7b02e1c7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -43,6 +43,7 @@ "transient", "--config=${workspaceRoot}/themes/jandedobbeleer.omp.json", "--shell=pwsh", + "--error=1" ] }, { diff --git a/src/environment/shell.go b/src/environment/shell.go index 0cf61153..681f988c 100644 --- a/src/environment/shell.go +++ b/src/environment/shell.go @@ -9,7 +9,6 @@ import ( "io/ioutil" "log" "net/http" - "net/url" "oh-my-posh/regex" "os" "os/exec" @@ -239,9 +238,8 @@ func (env *ShellEnvironment) resolveConfigPath() { if len(env.CmdFlags.Config) == 0 { env.CmdFlags.Config = fmt.Sprintf("https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v%s/themes/default.omp.json", env.Version) } - location, err := url.ParseRequestURI(env.CmdFlags.Config) - if err == nil { - env.getConfigPath(location.String()) + if strings.HasPrefix(env.CmdFlags.Config, "https://") { + env.getConfigPath(env.CmdFlags.Config) return } // Cygwin path always needs the full path as we're on Windows but not really. diff --git a/src/shell/scripts/omp.ps1 b/src/shell/scripts/omp.ps1 index 5cd66ad0..128a6f87 100644 --- a/src/shell/scripts/omp.ps1 +++ b/src/shell/scripts/omp.ps1 @@ -62,7 +62,7 @@ function global:Initialize-ModuleSupport { $omp = "::OMP::" $config, $cleanPWD, $cleanPSWD = Get-PoshContext if ($env:POSH_TRANSIENT -eq $true) { - $standardOut = @(&$omp prompt print transient --pwd="$cleanPWD" --pswd="$cleanPSWD" --config="$config" 2>&1) + $standardOut = @(&$omp prompt print transient --error="$global:ERRORCODE" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$global:EXECUTIONTIME" --config="$config" 2>&1) $standardOut -join "`n" $env:POSH_TRANSIENT = $false return @@ -72,16 +72,16 @@ function global:Initialize-ModuleSupport { $standardOut -join "`n" return } - $errorCode = 0 + $global:ERRORCODE = 0 Initialize-ModuleSupport Set-PoshContext if ($lastCommandSuccess -eq $false) { #native app exit code if ($realLASTEXITCODE -is [int] -and $realLASTEXITCODE -gt 0) { - $errorCode = $realLASTEXITCODE + $global:ERRORCODE = $realLASTEXITCODE } else { - $errorCode = 1 + $global:ERRORCODE = 1 } } @@ -94,14 +94,14 @@ function global:Initialize-ModuleSupport { } catch {} - $executionTime = -1 + $global:EXECUTIONTIME = -1 $history = Get-History -ErrorAction Ignore -Count 1 if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime -and $global:omp_lastHistoryId -ne $history.Id) { - $executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds + $global:EXECUTIONTIME = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds $global:omp_lastHistoryId = $history.Id } $terminalWidth = $Host.UI.RawUI.WindowSize.Width - $standardOut = @(&$omp prompt print primary --error="$errorCode" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$executionTime" --stack-count="$stackCount" --config="$config" --terminal-width=$terminalWidth 2>&1) + $standardOut = @(&$omp prompt print primary --error="$global:ERRORCODE" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$global:EXECUTIONTIME" --stack-count="$stackCount" --config="$config" --terminal-width=$terminalWidth 2>&1) # make sure PSReadLine knows we have a multiline prompt $extraLines = $standardOut.Count - 1 if ($extraLines -gt 0) { diff --git a/src/shell/scripts/omp.zsh b/src/shell/scripts/omp.zsh index 57d15e0d..3cc8586d 100644 --- a/src/shell/scripts/omp.zsh +++ b/src/shell/scripts/omp.zsh @@ -20,9 +20,6 @@ function prompt_ohmyposh_precmd() { eval "$(::OMP:: prompt print primary --config="$POSH_THEME" --error="$omp_last_error" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --eval --shell=zsh)" unset omp_start_time unset omp_now - unset omp_elapsed - unset omp_last_error - unset omp_stack_count } function _install-omp-hooks() { @@ -73,7 +70,7 @@ _posh-zle-line-init() { local -i ret=$? (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2] - eval "$(::OMP:: prompt print transient --config="$POSH_THEME" --eval --shell=zsh)" + eval "$(::OMP:: prompt print transient --error="$omp_last_error" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" --config="$POSH_THEME" --eval --shell=zsh)" zle .reset-prompt # If we received EOT, we exit the shell