mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
parent
b3b5267605
commit
bb9b6197d5
|
@ -13,7 +13,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
print bool
|
print bool
|
||||||
|
strict bool
|
||||||
|
|
||||||
initCmd = &cobra.Command{
|
initCmd = &cobra.Command{
|
||||||
Use: "init [bash|zsh|fish|powershell|pwsh|cmd|nu] --config ~/.mytheme.omp.json",
|
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
|
func init() { // nolint:gochecknoinits
|
||||||
initCmd.Flags().BoolVarP(&print, "print", "p", false, "print the init script")
|
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")
|
_ = initCmd.MarkPersistentFlagRequired("config")
|
||||||
rootCmd.AddCommand(initCmd)
|
rootCmd.AddCommand(initCmd)
|
||||||
}
|
}
|
||||||
|
@ -52,6 +54,7 @@ func runInit(shellName string) {
|
||||||
CmdFlags: &environment.Flags{
|
CmdFlags: &environment.Flags{
|
||||||
Shell: shellName,
|
Shell: shellName,
|
||||||
Config: config,
|
Config: config,
|
||||||
|
Strict: strict,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
env.Init(false)
|
env.Init(false)
|
||||||
|
|
|
@ -42,6 +42,7 @@ type Flags struct {
|
||||||
StackCount int
|
StackCount int
|
||||||
Migrate bool
|
Migrate bool
|
||||||
TerminalWidth int
|
TerminalWidth int
|
||||||
|
Strict bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandError struct {
|
type CommandError struct {
|
||||||
|
|
|
@ -38,6 +38,9 @@ func getExecutablePath(env environment.Environment) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
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
|
// On Windows, it fails when the excutable is called in MSYS2 for example
|
||||||
// which uses unix style paths to resolve the executable's location.
|
// 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.
|
// PowerShell knows how to resolve both, so we can swap this without any issue.
|
||||||
|
|
Loading…
Reference in a new issue