From 4c0db9e66e712879b314984a8899322cafa0bb0d Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Fri, 29 Apr 2022 20:28:29 +0800 Subject: [PATCH] fix(config): do not resolve URL when download fails --- docs/docs/installation/windows.mdx | 2 +- src/engine/config.go | 2 +- src/environment/shell.go | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/docs/installation/windows.mdx b/docs/docs/installation/windows.mdx index 14a63e70..ebad4304 100644 --- a/docs/docs/installation/windows.mdx +++ b/docs/docs/installation/windows.mdx @@ -144,7 +144,7 @@ when setting the prompt using the `--config` flag. -You can find the themes winget installs inside the `$env:POSH_THEMES_PATH` folder. +You can find the themes inside the `$env:POSH_THEMES_PATH` folder. To use `jandedobbeleer.omp.json` for example, you can refer to it using `$env:POSH_THEMES_PATH\jandedobbeleer.omp.json` when setting the prompt using the `--config` flag. diff --git a/src/engine/config.go b/src/engine/config.go index 0cb8cfac..ac63f7c3 100644 --- a/src/engine/config.go +++ b/src/engine/config.go @@ -281,7 +281,7 @@ func defaultConfig() *Config { BackgroundTemplates: []string{ "{{ if gt .Code 0 }}#f1184c{{ end }}", }, - Template: " \uE23A", + Template: " \uE23A ", Properties: properties.Map{ properties.AlwaysEnabled: true, }, diff --git a/src/environment/shell.go b/src/environment/shell.go index 1003405b..9066f254 100644 --- a/src/environment/shell.go +++ b/src/environment/shell.go @@ -234,13 +234,15 @@ func (env *ShellEnvironment) resolveConfigPath() { env.CmdFlags.Config = fmt.Sprintf("https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v%s/themes/default.omp.json", env.Version) } if strings.HasPrefix(env.CmdFlags.Config, "https://") { - if err := env.downloadConfig(env.CmdFlags.Config); err == nil { + if err := env.downloadConfig(env.CmdFlags.Config); err != nil { + // make it use default config when download fails + env.CmdFlags.Config = "" return } } // Cygwin path always needs the full path as we're on Windows but not really. // Doing filepath actions will convert it to a Windows path and break the init script. - if env.Platform() == WindowsPlatform && env.Shell() == "constants.BASH" { + if env.Platform() == WindowsPlatform && env.Shell() == "bash" { return } configFile := env.CmdFlags.Config @@ -569,7 +571,7 @@ func (env *ShellEnvironment) Shell() string { return Unknown } // Cache the shell value to speed things up. - env.CmdFlags.Shell = strings.Trim(strings.Replace(name, ".exe", "", 1), " ") + env.CmdFlags.Shell = strings.Trim(strings.TrimSuffix(name, ".exe"), " ") return env.CmdFlags.Shell }