-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store everything in XDG_CONFIG_HOME, add
status
command
- Loading branch information
Showing
4 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package config | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func Path(filename string) (string, error) { | ||
configHome := os.Getenv("XDG_CONFIG_HOME") | ||
if configHome == "" { | ||
home := os.Getenv("HOME") | ||
if home == "" { | ||
return "", errors.New("HOME not set") | ||
} | ||
configHome = filepath.Join(home, ".config") | ||
} | ||
|
||
p := filepath.Join(configHome, "hydroxide", filename) | ||
|
||
dirname, _ := filepath.Split(p) | ||
if err := os.MkdirAll(dirname, 0700); err != nil { | ||
return "", err | ||
} | ||
|
||
return p, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters