fix: add input to history before alias expansion

since im stupid, normal commands that are aliased add
the expanded version to the history, and not the alias itself.
lua alias was added since im dumb and did `input` instead of `cmdString`
so now, history is handled once, in main.go
pull/59/head
sammyette 2021-05-16 20:09:47 -04:00
parent 12828d197a
commit 1ff3ff854b
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
2 changed files with 8 additions and 13 deletions

View File

@ -158,6 +158,7 @@ func main() {
}
}
running = true
HandleHistory(input)
RunInput(input)
termwidth, _, err := term.GetSize(0)
@ -218,3 +219,10 @@ func HandleSignals() {
}
}
}
func HandleHistory(cmd string) {
readline.AddHistory(cmd)
readline.SaveHistory(homedir + "/.hilbish-history")
// TODO: load history again (history shared between sessions like this ye)
}

View File

@ -45,9 +45,6 @@ func RunInput(input string) {
err = l.PCall(0, lua.MultRet, nil)
}
if err == nil {
// If it succeeds, add to history and prompt again
HandleHistory(input)
hooks.Em.Emit("command.exit", 0)
return
}
@ -75,9 +72,6 @@ func RunInput(input string) {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
}
if cmdArgs[0] != "exit" {
HandleHistory(cmdString)
}
hooks.Em.Emit("command.exit", exitcode)
return
}
@ -113,7 +107,6 @@ func RunInput(input string) {
} else {
hooks.Em.Emit("command.exit", 0)
}
HandleHistory(cmdString)
}
// Run command in sh interpreter
@ -183,9 +176,3 @@ func splitInput(input string) ([]string, string) {
return cmdArgs, cmdstr.String()
}
func HandleHistory(cmd string) {
readline.AddHistory(cmd)
readline.SaveHistory(homedir + "/.hilbish-history")
// TODO: load history again (history shared between sessions like this ye)
}