diff --git a/lua.go b/lua.go index 90f89ee..9708338 100644 --- a/lua.go +++ b/lua.go @@ -59,6 +59,13 @@ func LuaInit() { hooks = bait.New() l.PreloadModule("bait", hooks.Loader) + // Add Ctrl-C handler + hooks.Em.On("signal.sigint", func() { + if !interactive { + os.Exit(0) + } + }) + l.SetGlobal("complete", l.NewFunction(hshcomplete)) // Add more paths that Lua can require from diff --git a/main.go b/main.go index 9e21d2b..f0909c2 100644 --- a/main.go +++ b/main.go @@ -265,13 +265,12 @@ func HandleSignals() { for s := range c { switch s { case os.Interrupt: + hooks.Em.Emit("signals.sigint") if !running { - if !interactive { - os.Exit(0) - } lr.ClearInput() } case syscall.SIGWINCH: + hooks.Em.Emit("signals.resize") if !running { lr.Resize() }