diff options
-rw-r--r-- | main.go | 2 | ||||
-rw-r--r-- | pkg/config/app_config.go | 17 |
2 files changed, 13 insertions, 6 deletions
@@ -100,7 +100,7 @@ func main() { } if configDirFlag { - fmt.Printf("%s\n", config.ConfigDir()) + fmt.Printf("%s\n", config.ConfigDir("jesseduffield")) os.Exit(0) } diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index b4671e047..787d2a8e0 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -81,21 +81,28 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg return appConfig, nil } -func ConfigDir() string { +func SelectDefaultConfiguration() string { + configDirectory := ConfigDir("") + if _, err := os.Stat(configDirectory); !os.IsNotExist(err) { + return configDirectory + } + legacyConfigDirectory := ConfigDir("jesseduffield") + return legacyConfigDirectory +} + +func ConfigDir(vendor string) string { envConfigDir := os.Getenv("CONFIG_DIR") if envConfigDir != "" { return envConfigDir } - // chucking my name there is not for vanity purposes, the xdg spec (and that // function) requires a vendor name. May as well line up with github - configDirs := xdg.New("jesseduffield", "lazygit") + configDirs := xdg.New(vendor, "lazygit") return configDirs.ConfigHome() } func findOrCreateConfigDir() (string, error) { - folder := ConfigDir() - + folder := SelectDefaultConfiguration() err := os.MkdirAll(folder, 0755) if err != nil { return "", err |