mirror of
https://github.com/agresdominik/cheat_sheet.git
synced 2026-04-21 10:01:58 +00:00
Changed install to be in userspace and no root is required
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
EXECUTABLE = cheatsh
|
||||
PACKAGES = ./src/.
|
||||
BINDIR = bin
|
||||
SYSCONFDIR = /etc/cheatsh
|
||||
PREFIX ?= /usr/local
|
||||
SYSCONFDIR = $(HOME)/.config/cheatsh
|
||||
PREFIX ?= $(HOME)/.local
|
||||
|
||||
all: build
|
||||
|
||||
|
||||
+12
-2
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"sort"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type CmdGroup struct {
|
||||
@@ -39,10 +40,19 @@ func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
configFile := "/etc/cheatsh/commands.json"
|
||||
var configFile string
|
||||
|
||||
home, err := os.UserHomeDir()
|
||||
if err == nil {
|
||||
userConf := filepath.Join(home, ".config", "cheatsh")
|
||||
if info, err := os.Stat(userConf); err == nil && info.IsDir() {
|
||||
configFile = filepath.Join(userConf, "commands.json")
|
||||
} else {
|
||||
configFile = "/etc/cheatsh/commands.json"
|
||||
}
|
||||
}
|
||||
|
||||
var commands CmdList
|
||||
var err error
|
||||
|
||||
if *configFlag != "" {
|
||||
commands, err = loadCommands(*configFlag)
|
||||
|
||||
Reference in New Issue
Block a user