diff --git a/src/cli/init.go b/src/cli/init.go index 45a827a3..92228927 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -13,7 +13,8 @@ import ( ) var ( - print bool + print bool + strict 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/prompt 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.MarkPersistentFlagRequired("config") rootCmd.AddCommand(initCmd) } @@ -52,6 +54,7 @@ func runInit(shellName string) { CmdFlags: &environment.Flags{ Shell: shellName, Config: config, + Strict: strict, }, } env.Init(false) diff --git a/src/environment/shell.go b/src/environment/shell.go index efccd24b..60d1fe60 100644 --- a/src/environment/shell.go +++ b/src/environment/shell.go @@ -42,6 +42,7 @@ type Flags struct { StackCount int Migrate bool TerminalWidth int + Strict bool } type CommandError struct { diff --git a/src/shell/init.go b/src/shell/init.go index 12585148..b48e8cc4 100644 --- a/src/shell/init.go +++ b/src/shell/init.go @@ -38,6 +38,9 @@ func getExecutablePath(env environment.Environment) (string, error) { if err != nil { return "", err } + if env.Flags().Strict { + return environment.Base(env, executable), nil + } // On Windows, it fails when the excutable is called in MSYS2 for example // which uses unix style paths to resolve the executable's location. // PowerShell knows how to resolve both, so we can swap this without any issue.