2
3
의 미러 https://github.com/sammy-ette/Hilbish synced 2025-08-10 02:52:03 +00:00

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
This commit is contained in:
sammyette 2021-05-16 20:09:47 -04:00
부모 12828d197a
커밋 1ff3ff854b
No known key found for this signature in database
GPG 키 ID: 50EE40A2809851F5
2개의 변경된 파일8개의 추가작업 그리고 13개의 파일을 삭제

파일 보기

@ -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)
}

파일 보기

@ -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)
}