diff --git a/api.go b/api.go index cd17f49..cec7165 100644 --- a/api.go +++ b/api.go @@ -65,6 +65,7 @@ The nice lil shell for {blue}Lua{reset} fanatics! util.SetField(L, mod, "login", lua.LBool(interactive), "Whether this is a login shell") util.SetField(L, mod, "greeting", lua.LString(greeting), "Hilbish's welcome message for interactive shells. It has Lunacolors formatting.") util.SetField(l, mod, "vimMode", lua.LNil, "Current Vim mode of Hilbish (nil if not in Vim mode)") + util.SetField(l, hshMod, "exitCode", lua.LNumber(0), "Exit code of last exected command") util.Document(L, mod, "Hilbish's core API, containing submodules and functions which relate to the shell itself.") // hilbish.userDir table diff --git a/exec.go b/exec.go index ac68c07..b3a1bdb 100644 --- a/exec.go +++ b/exec.go @@ -244,5 +244,6 @@ func cmdFinish(code uint8, cmdstr, oldInput string) { if !strings.HasPrefix(oldInput, " ") || interactive { handleHistory(cmdstr) } + util.SetField(l, hshMod, "exitCode", lua.LNumber(code), "Exit code of last exected command") hooks.Em.Emit("command.exit", code, cmdstr) }