diff --git a/src/cli/init.go b/src/cli/init.go index e598ee77..0f36c1d3 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -12,6 +12,7 @@ import ( var ( print bool strict bool + manual bool initCmd = &cobra.Command{ Use: "init [bash|zsh|fish|powershell|pwsh|cmd|nu] --config ~/.mytheme.omp.json", @@ -42,6 +43,7 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/instal func init() { //nolint:gochecknoinits initCmd.Flags().BoolVarP(&print, "print", "p", false, "print the init script") initCmd.Flags().BoolVarP(&strict, "strict", "s", false, "run in strict mode") + initCmd.Flags().BoolVarP(&manual, "manual", "m", false, "enable/disable manual mode") _ = initCmd.MarkPersistentFlagRequired("config") rootCmd.AddCommand(initCmd) } @@ -53,6 +55,7 @@ func runInit(shellName string) { Shell: shellName, Config: config, Strict: strict, + Manual: manual, }, } env.Init() diff --git a/src/environment/shell.go b/src/environment/shell.go index fda77a9a..a31bb717 100644 --- a/src/environment/shell.go +++ b/src/environment/shell.go @@ -54,6 +54,7 @@ type Flags struct { TerminalWidth int Strict bool Debug bool + Manual bool } type CommandError struct { diff --git a/src/shell/init.go b/src/shell/init.go index b2de0ae6..c148f11b 100644 --- a/src/shell/init.go +++ b/src/shell/init.go @@ -174,6 +174,14 @@ func PrintInit(env environment.Environment) string { if err != nil { return noExe } + + toggleSetting := func(setting bool) string { + if env.Flags().Manual { + return "false" + } + return strconv.FormatBool(setting) + } + shell := env.Flags().Shell configFile := env.Flags().Config var script string @@ -209,9 +217,9 @@ func PrintInit(env environment.Environment) string { "::OMP::", executable, "::CONFIG::", configFile, "::SHELL::", shell, - "::TRANSIENT::", strconv.FormatBool(Transient), - "::ERROR_LINE::", strconv.FormatBool(ErrorLine), - "::TOOLTIPS::", strconv.FormatBool(Tooltips), + "::TRANSIENT::", toggleSetting(Transient), + "::ERROR_LINE::", toggleSetting(ErrorLine), + "::TOOLTIPS::", toggleSetting(Tooltips), ).Replace(script) }