diff options
author | Nick Flueckiger <nick.flueckiger@renuo.ch> | 2020-11-08 17:49:29 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 10:42:38 +1100 |
commit | 669bfe763a3f36ec73559e299e0098d422fd77bf (patch) | |
tree | 37946e63fa99b17a8d9b09acb3c895639b27df08 | |
parent | 860370a8456370aeb57a06d27e5a248351071b80 (diff) |
A small change that enables direct lazygit directory config
-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 |