diff --git a/src/cli/enable.go b/src/cli/enable.go index cdcf8e30..bf634883 100644 --- a/src/cli/enable.go +++ b/src/cli/enable.go @@ -3,6 +3,8 @@ package cli import ( "fmt" + "github.com/jandedobbeleer/oh-my-posh/src/cache" + "github.com/jandedobbeleer/oh-my-posh/src/config" "github.com/jandedobbeleer/oh-my-posh/src/runtime" "github.com/jandedobbeleer/oh-my-posh/src/upgrade" @@ -18,6 +20,7 @@ This command is used to %s one of the following features: - notice` toggleArgs = []string{ "notice", + "autoupgrade", } ) @@ -59,7 +62,14 @@ func toggleFeature(cmd *cobra.Command, feature string, enable bool) { return } - env.Cache().Set(upgrade.CACHEKEY, "disabled", -1) + env.Cache().Set(upgrade.CACHEKEY, "disabled", cache.INFINITE) + case "autoupgrade": + if enable { + env.Cache().Set(config.AUTOUPGRADE, "true", cache.INFINITE) + return + } + + env.Cache().Delete(config.AUTOUPGRADE) default: _ = cmd.Help() } diff --git a/src/config/config.go b/src/config/config.go index 3f77b8e9..ab97edad 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -14,6 +14,8 @@ const ( YAML string = "yaml" TOML string = "toml" + AUTOUPGRADE = "auto_upgrade" + Version = 2 ) @@ -103,11 +105,16 @@ func (cfg *Config) Features() shell.Features { feats = append(feats, shell.FTCSMarks) } - if !cfg.AutoUpgrade && !cfg.DisableNotice { + autoUpgrade := cfg.AutoUpgrade + if _, OK := cfg.env.Cache().Get(AUTOUPGRADE); OK { + autoUpgrade = true + } + + if !autoUpgrade && !cfg.DisableNotice { feats = append(feats, shell.Notice) } - if cfg.AutoUpgrade { + if autoUpgrade { feats = append(feats, shell.Upgrade) } diff --git a/src/upgrade/notice.go b/src/upgrade/notice.go index a95a3a22..d4661106 100644 --- a/src/upgrade/notice.go +++ b/src/upgrade/notice.go @@ -38,7 +38,7 @@ const ( A new release of Oh My Posh is available: %s → %s To upgrade, run: 'oh-my-posh upgrade' -To enable automated upgrades, set 'auto_upgrade' to 'true' in your configuration. +To enable automated upgrades, run: 'oh-my-posh enable autoupgrade'. ` )