allow custom history path
This commit is contained in:
parent
04128fc629
commit
ef3ebf0135
1 changed files with 9 additions and 4 deletions
13
main.go
13
main.go
|
@ -18,6 +18,7 @@ var (
|
||||||
noPersist = app.Flag("no-persist", "Don't persist a copy buffer after a program exits").Short('P').Default("false").Bool()
|
noPersist = app.Flag("no-persist", "Don't persist a copy buffer after a program exits").Short('P').Default("false").Bool()
|
||||||
max = app.Flag("max-items", "items to store in history (with -d) or display before scrolling (with -s)").Default("15").Int()
|
max = app.Flag("max-items", "items to store in history (with -d) or display before scrolling (with -s)").Default("15").Int()
|
||||||
tool = app.Flag("selector", "Which selector to use: dmenu/rofi").Default("dmenu").String()
|
tool = app.Flag("selector", "Which selector to use: dmenu/rofi").Default("dmenu").String()
|
||||||
|
histpath = app.Flag("histpath", "Directory where to save history").Default("$XDG_DATA_HOME").String()
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -38,11 +39,15 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
h, err := os.UserHomeDir()
|
histpath := *histpath
|
||||||
if err != nil {
|
if histpath == "$XDG_DATA_HOME" {
|
||||||
log.Fatal(err)
|
home, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
histpath = path.Join(home, ".local/share/")
|
||||||
}
|
}
|
||||||
histfile := path.Join(h, ".local/share/clipman.json")
|
histfile := path.Join(histpath, "clipman.json")
|
||||||
|
|
||||||
var history []string
|
var history []string
|
||||||
b, err := ioutil.ReadFile(histfile)
|
b, err := ioutil.ReadFile(histfile)
|
||||||
|
|
Loading…
Reference in a new issue