mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-31 04:51:13 -08:00
parent
8dada3cbaf
commit
94a379b26a
|
@ -12,6 +12,7 @@ import (
|
||||||
var (
|
var (
|
||||||
print bool
|
print bool
|
||||||
strict bool
|
strict bool
|
||||||
|
manual 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/instal
|
||||||
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.Flags().BoolVarP(&strict, "strict", "s", false, "run in strict mode")
|
||||||
|
initCmd.Flags().BoolVarP(&manual, "manual", "m", false, "enable/disable manual mode")
|
||||||
_ = initCmd.MarkPersistentFlagRequired("config")
|
_ = initCmd.MarkPersistentFlagRequired("config")
|
||||||
rootCmd.AddCommand(initCmd)
|
rootCmd.AddCommand(initCmd)
|
||||||
}
|
}
|
||||||
|
@ -53,6 +55,7 @@ func runInit(shellName string) {
|
||||||
Shell: shellName,
|
Shell: shellName,
|
||||||
Config: config,
|
Config: config,
|
||||||
Strict: strict,
|
Strict: strict,
|
||||||
|
Manual: manual,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
env.Init()
|
env.Init()
|
||||||
|
|
|
@ -54,6 +54,7 @@ type Flags struct {
|
||||||
TerminalWidth int
|
TerminalWidth int
|
||||||
Strict bool
|
Strict bool
|
||||||
Debug bool
|
Debug bool
|
||||||
|
Manual bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandError struct {
|
type CommandError struct {
|
||||||
|
|
|
@ -174,6 +174,14 @@ func PrintInit(env environment.Environment) string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return noExe
|
return noExe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleSetting := func(setting bool) string {
|
||||||
|
if env.Flags().Manual {
|
||||||
|
return "false"
|
||||||
|
}
|
||||||
|
return strconv.FormatBool(setting)
|
||||||
|
}
|
||||||
|
|
||||||
shell := env.Flags().Shell
|
shell := env.Flags().Shell
|
||||||
configFile := env.Flags().Config
|
configFile := env.Flags().Config
|
||||||
var script string
|
var script string
|
||||||
|
@ -209,9 +217,9 @@ func PrintInit(env environment.Environment) string {
|
||||||
"::OMP::", executable,
|
"::OMP::", executable,
|
||||||
"::CONFIG::", configFile,
|
"::CONFIG::", configFile,
|
||||||
"::SHELL::", shell,
|
"::SHELL::", shell,
|
||||||
"::TRANSIENT::", strconv.FormatBool(Transient),
|
"::TRANSIENT::", toggleSetting(Transient),
|
||||||
"::ERROR_LINE::", strconv.FormatBool(ErrorLine),
|
"::ERROR_LINE::", toggleSetting(ErrorLine),
|
||||||
"::TOOLTIPS::", strconv.FormatBool(Tooltips),
|
"::TOOLTIPS::", toggleSetting(Tooltips),
|
||||||
).Replace(script)
|
).Replace(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue