1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-03 13:21:56 +02:00

A small change that enables direct lazygit directory config

This commit is contained in:
Nick Flueckiger 2020-11-08 17:49:29 +01:00 committed by Jesse Duffield
parent 860370a845
commit 669bfe763a
2 changed files with 13 additions and 6 deletions

View File

@ -100,7 +100,7 @@ func main() {
}
if configDirFlag {
fmt.Printf("%s\n", config.ConfigDir())
fmt.Printf("%s\n", config.ConfigDir("jesseduffield"))
os.Exit(0)
}

View File

@ -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