mirror of https://github.com/Hilbis/Hilbish
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.gopull/59/head
parent
12828d197a
commit
1ff3ff854b
8
main.go
8
main.go
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
13
shell.go
13
shell.go
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue