mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 11:59:40 -08:00
parent
b3b5267605
commit
bb9b6197d5
|
@ -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)
|
||||
|
|
|
@ -42,6 +42,7 @@ type Flags struct {
|
|||
StackCount int
|
||||
Migrate bool
|
||||
TerminalWidth int
|
||||
Strict bool
|
||||
}
|
||||
|
||||
type CommandError struct {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue