Merge pull request #50 from erAck/fix-home-expansion

"~/" does not work as hoped for
This commit is contained in:
2019-12-16 07:48:00 -05:00
committed by GitHub

View File

@ -50,7 +50,7 @@ func cmdConfig(cmd []string) {
func readConfig(filepath ...string) (*Config, error) {
var result = new(Config)
var configFile string
var configFile, path string
var env bool
// Load default config first, this way any values missing from the provided config file will remain the default value
@ -61,10 +61,15 @@ func readConfig(filepath ...string) (*Config, error) {
case 0:
configFile, env = os.LookupEnv("KBTUI_CFG")
if !env {
configFile = "~/.config/kbtui.toml"
path, env = os.LookupEnv("HOME")
if env {
configFile = path + "/.config/kbtui.toml"
if _, err := os.Stat(configFile); os.IsNotExist(err) {
configFile = "kbtui.toml"
}
} else {
configFile = "kbtui.toml"
}
}
default:
configFile = filepath[0]