Compare commits

..

No commits in common. "4b57dc2ed887655ac91e36da3b1250e88e16a479" and "29c1e29bb72b95399aed628222bf818f600c7ab0" have entirely different histories.

11 changed files with 9 additions and 35 deletions

View File

@ -1,9 +1,8 @@
-- Default Hilbish config -- Default Hilbish config
local lunacolors = require 'lunacolors' local lunacolors = require 'lunacolors'
local bait = require 'bait' local bait = require 'bait'
local ansikit = require 'ansikit'
local function doPrompt(fail, mode) function doPrompt(fail)
hilbish.prompt(lunacolors.format( hilbish.prompt(lunacolors.format(
'{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. '' '{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. ''
)) ))
@ -17,12 +16,3 @@ bait.catch('command.exit', function(code)
doPrompt(code ~= 0) doPrompt(code ~= 0)
end) end)
bait.catch('hilbish.vimMode', function(mode)
if mode ~= 'insert' then
ansikit.cursorStyle(ansikit.blockCursor)
else
ansikit.cursorStyle(ansikit.lineCursor)
end
doPrompt(false, mode)
end)

3
api.go
View File

@ -65,7 +65,6 @@ 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, "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, "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, 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.") util.Document(L, mod, "Hilbish's core API, containing submodules and functions which relate to the shell itself.")
// hilbish.userDir table // hilbish.userDir table
@ -155,8 +154,8 @@ func luaBinaryComplete(L *lua.LState) int {
} }
func setVimMode(mode string) { func setVimMode(mode string) {
util.SetField(l, hshMod, "vimMode", lua.LString(mode), "Current Vim mode of Hilbish (nil if not in Vim mode)")
hooks.Em.Emit("hilbish.vimMode", mode) hooks.Em.Emit("hilbish.vimMode", mode)
util.SetField(l, hshMod, "vimMode", lua.LString(mode), "Current Vim mode of Hilbish (nil if not in Vim mode)")
} }
func unsetVimMode() { func unsetVimMode() {

View File

@ -1,3 +0,0 @@
+ `hilbish.exit` > Sent when Hilbish is about to exit.
+ `hilbish.vimMode` > Sent when Hilbish's Vim mode is changed (example insert to normal mode)

View File

@ -1,5 +1,5 @@
Here is a list of bait hooks that are thrown by Hilbish. If a hook is related Here is listed all scopes for bait hooks. If a hook is related to a command,
to a command, it will have the `command` scope, as example. it will have the `command` scope, as example.
Here is the format for a doc for a hook: Here is the format for a doc for a hook:
+ <hook name> -> <args> > <description> + <hook name> -> <args> > <description>

View File

@ -1,7 +1,4 @@
+ `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C). + `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C).
+ `signal.resize` > Sent when the terminal is resized. + `signal.resize` > Sent when the terminal is resized.
+ `signal.sigusr1` + `signal.sigusr1`
+ `signal.sigusr2` + `signal.sigusr2`

View File

@ -244,6 +244,5 @@ func cmdFinish(code uint8, cmdstr, oldInput string) {
if !strings.HasPrefix(oldInput, " ") || interactive { if !strings.HasPrefix(oldInput, " ") || interactive {
handleHistory(cmdstr) handleHistory(cmdstr)
} }
util.SetField(l, hshMod, "exitCode", lua.LNumber(code), "Exit code of last exected command")
hooks.Em.Emit("command.exit", code, cmdstr) hooks.Em.Emit("command.exit", code, cmdstr)
} }

2
go.mod
View File

@ -14,7 +14,7 @@ require (
mvdan.cc/sh/v3 v3.4.3 mvdan.cc/sh/v3 v3.4.3
) )
replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5
replace github.com/maxlandon/readline => github.com/Rosettea/readline-1 v0.0.0-20220305123014-31d4d4214c93 replace github.com/maxlandon/readline => github.com/Rosettea/readline-1 v0.0.0-20220305123014-31d4d4214c93

2
go.sum
View File

@ -10,8 +10,6 @@ github.com/Rosettea/readline-1 v0.1.0-beta.0.20220228022904-61f5e4493011 h1:+a61
github.com/Rosettea/readline-1 v0.1.0-beta.0.20220228022904-61f5e4493011/go.mod h1:QiUAvbhg8PzCA4hlafCUl0bKD/0VmcocM4AjqtszAJs= github.com/Rosettea/readline-1 v0.1.0-beta.0.20220228022904-61f5e4493011/go.mod h1:QiUAvbhg8PzCA4hlafCUl0bKD/0VmcocM4AjqtszAJs=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5 h1:ygwVRX8gf5MHA0VzSgOdscCEoAJLjM8joEotfQPgAd0= github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5 h1:ygwVRX8gf5MHA0VzSgOdscCEoAJLjM8joEotfQPgAd0=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5/go.mod h1:R09vh/04ILvP2Gj8/Z9Jd0Dh0ZIvaucowMEs6abQpWs= github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5/go.mod h1:R09vh/04ILvP2Gj8/Z9Jd0Dh0ZIvaucowMEs6abQpWs=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e h1:P2XupP8SaylWaudD1DqbWtZ3mIa8OsE9635LmR+Q+lg=
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e/go.mod h1:R09vh/04ILvP2Gj8/Z9Jd0Dh0ZIvaucowMEs6abQpWs=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c= github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c=

View File

@ -1,12 +1,8 @@
-- We're basically porting Ansikit to lua
-- https://github.com/Luvella/AnsiKit/blob/master/lib/index.js
-- which is made by yours truly sammy :^)
local lunacolors = require 'lunacolors' local lunacolors = require 'lunacolors'
local ansikit = { local ansikit = {}
blockCursor = 1,
blockCursorSteady = 2,
underlineCursor = 3,
underlineCursorSteady = 4,
lineCursor = 5,
lineCursorSteady = 6,
}
ansikit.clear = function(scrollback) ansikit.clear = function(scrollback)
local typ = (scrollback and 3 or 2) local typ = (scrollback and 3 or 2)

View File

@ -172,7 +172,6 @@ input:
if err == io.EOF { if err == io.EOF {
// Exit if user presses ^D (ctrl + d) // Exit if user presses ^D (ctrl + d)
hooks.Em.Emit("hilbish.exit")
break break
} }
if err != nil { if err != nil {

View File

@ -45,7 +45,6 @@ commander.register('cd', function (args)
end) end)
commander.register('exit', function() commander.register('exit', function()
bait.throw('hilbish.exit')
os.exit(0) os.exit(0)
end) end)