의 미러
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:
부모
12828d197a
커밋
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)
|
||||
}
|
||||
|
||||
|
불러오는 중...
x
Reference in New Issue
Block a user