mirror of https://github.com/Hilbis/Hilbish
feat: add default history dir to xdg dir, or fallback to home
parent
b387b18923
commit
0977110e79
13
main.go
13
main.go
|
@ -32,6 +32,7 @@ var (
|
|||
|
||||
hooks bait.Bait
|
||||
defaultConfPath string
|
||||
defaultHistPath string
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -52,7 +53,17 @@ func main() {
|
|||
// else do ~ substitution
|
||||
defaultConfPath = filepath.Join(strings.Replace(defaultConfDir, "~", homedir, 1), ".hilbishrc.lua")
|
||||
}
|
||||
|
||||
if defaultHistDir == "" {
|
||||
// we'll add *our* default if its empty (wont be if its changed comptime)
|
||||
if _, err := os.Stat(filepath.Join(confDir, "hilbish")); os.IsNotExist(err) {
|
||||
defaultHistPath = filepath.Join(homedir, "/.hilbish-history")
|
||||
} else {
|
||||
defaultHistPath = filepath.Join(confDir, "hilbish", ".hilbish-history")
|
||||
}
|
||||
} else {
|
||||
// else do ~ substitution
|
||||
defaultHistPath = filepath.Join(strings.Replace(defaultHistDir, "~", homedir, 1), ".hilbishrc.lua")
|
||||
}
|
||||
helpflag := getopt.BoolLong("help", 'h', "Prints Hilbish flags")
|
||||
verflag := getopt.BoolLong("version", 'v', "Prints Hilbish version")
|
||||
setshflag := getopt.BoolLong("setshellenv", 'S', "Sets $SHELL to Hilbish's executed path")
|
||||
|
|
4
rl.go
4
rl.go
|
@ -14,7 +14,7 @@ type LineReader struct {
|
|||
// other gophers might hate this naming but this is local, shut up
|
||||
func NewLineReader(prompt string) *LineReader {
|
||||
readline.Completer = readline.FilenameCompleter
|
||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||
readline.LoadHistory(defaultHistPath)
|
||||
|
||||
return &LineReader{
|
||||
Prompt: prompt,
|
||||
|
@ -31,7 +31,7 @@ func (lr *LineReader) SetPrompt(prompt string) {
|
|||
|
||||
func (lr *LineReader) AddHistory(cmd string) {
|
||||
readline.AddHistory(cmd)
|
||||
readline.SaveHistory(homedir + "/.hilbish-history")
|
||||
readline.SaveHistory(defaultHistPath)
|
||||
}
|
||||
|
||||
func (lr *LineReader) ClearInput() {
|
||||
|
|
Loading…
Reference in New Issue