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
|
EXECUTABLE = cheatsh
|
||||||
PACKAGES = ./src/.
|
PACKAGES = ./src/.
|
||||||
BINDIR = bin
|
BINDIR = bin
|
||||||
SYSCONFDIR = /etc/cheatsh
|
SYSCONFDIR = $(HOME)/.config/cheatsh
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= $(HOME)/.local
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"sort"
|
"sort"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CmdGroup struct {
|
type CmdGroup struct {
|
||||||
@@ -39,10 +40,19 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
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 commands CmdList
|
||||||
var err error
|
|
||||||
|
|
||||||
if *configFlag != "" {
|
if *configFlag != "" {
|
||||||
commands, err = loadCommands(*configFlag)
|
commands, err = loadCommands(*configFlag)
|
||||||
|
|||||||
Reference in New Issue
Block a user