mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Added CROC_CONFIG_DIR env var to support custom config dir path
This commit is contained in:
parent
6caf72df82
commit
c1e546ede6
1 changed files with 7 additions and 2 deletions
|
@ -130,10 +130,15 @@ func getConfigDir() (homedir string, err error) {
|
|||
log.Error(err)
|
||||
return
|
||||
}
|
||||
homedir = path.Join(homedir, ".config", "croc")
|
||||
if xdgConfigHome, isSet := os.LookupEnv("XDG_CONFIG_HOME"); isSet {
|
||||
|
||||
if envHomedir, isSet := os.LookupEnv("CROC_CONFIG_DIR"); isSet {
|
||||
homedir = envHomedir
|
||||
} else if xdgConfigHome, isSet := os.LookupEnv("XDG_CONFIG_HOME"); isSet {
|
||||
homedir = path.Join(xdgConfigHome, "croc")
|
||||
} else {
|
||||
homedir = path.Join(homedir, ".config", "croc")
|
||||
}
|
||||
|
||||
if _, err = os.Stat(homedir); os.IsNotExist(err) {
|
||||
log.Debugf("creating home directory %s", homedir)
|
||||
err = os.MkdirAll(homedir, 0700)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue