mirror of https://github.com/Hilbis/Hilbish
Compare commits
9 Commits
29c1e29bb7
...
4b57dc2ed8
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 4b57dc2ed8 | |
TorchedSammy | 928b829388 | |
TorchedSammy | 7b693908df | |
TorchedSammy | 8d8b298053 | |
TorchedSammy | 281c443b7b | |
TorchedSammy | 3805f13369 | |
TorchedSammy | 0b1b5bff2d | |
TorchedSammy | f8f8cd0b59 | |
TorchedSammy | 4bb65572e4 |
|
@ -1,8 +1,9 @@
|
|||
-- Default Hilbish config
|
||||
local lunacolors = require 'lunacolors'
|
||||
local bait = require 'bait'
|
||||
local ansikit = require 'ansikit'
|
||||
|
||||
function doPrompt(fail)
|
||||
local function doPrompt(fail, mode)
|
||||
hilbish.prompt(lunacolors.format(
|
||||
'{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. '∆ '
|
||||
))
|
||||
|
@ -16,3 +17,12 @@ bait.catch('command.exit', function(code)
|
|||
doPrompt(code ~= 0)
|
||||
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
3
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
|
||||
|
@ -154,8 +155,8 @@ func luaBinaryComplete(L *lua.LState) int {
|
|||
}
|
||||
|
||||
func setVimMode(mode string) {
|
||||
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)")
|
||||
hooks.Em.Emit("hilbish.vimMode", mode)
|
||||
}
|
||||
|
||||
func unsetVimMode() {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
+ `hilbish.exit` > Sent when Hilbish is about to exit.
|
||||
|
||||
+ `hilbish.vimMode` > Sent when Hilbish's Vim mode is changed (example insert to normal mode)
|
|
@ -1,5 +1,5 @@
|
|||
Here is listed all scopes for bait hooks. If a hook is related to a command,
|
||||
it will have the `command` scope, as example.
|
||||
Here is a list of bait hooks that are thrown by Hilbish. If a hook is related
|
||||
to a command, it will have the `command` scope, as example.
|
||||
|
||||
Here is the format for a doc for a hook:
|
||||
+ <hook name> -> <args> > <description>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
+ `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C).
|
||||
|
||||
+ `signal.resize` > Sent when the terminal is resized.
|
||||
|
||||
+ `signal.sigusr1`
|
||||
|
||||
+ `signal.sigusr2`
|
||||
|
|
1
exec.go
1
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)
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -14,7 +14,7 @@ require (
|
|||
mvdan.cc/sh/v3 v3.4.3
|
||||
)
|
||||
|
||||
replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20211022004519-f67a49cb50f5
|
||||
replace mvdan.cc/sh/v3 => github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20220306140409-795a84b00b4e
|
||||
|
||||
replace github.com/maxlandon/readline => github.com/Rosettea/readline-1 v0.0.0-20220305123014-31d4d4214c93
|
||||
|
||||
|
|
2
go.sum
2
go.sum
|
@ -10,6 +10,8 @@ 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/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.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/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
|
||||
github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c=
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
-- 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 ansikit = {}
|
||||
local ansikit = {
|
||||
blockCursor = 1,
|
||||
blockCursorSteady = 2,
|
||||
underlineCursor = 3,
|
||||
underlineCursorSteady = 4,
|
||||
lineCursor = 5,
|
||||
lineCursorSteady = 6,
|
||||
}
|
||||
|
||||
ansikit.clear = function(scrollback)
|
||||
local typ = (scrollback and 3 or 2)
|
||||
|
|
1
main.go
1
main.go
|
@ -172,6 +172,7 @@ input:
|
|||
|
||||
if err == io.EOF {
|
||||
// Exit if user presses ^D (ctrl + d)
|
||||
hooks.Em.Emit("hilbish.exit")
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -45,6 +45,7 @@ commander.register('cd', function (args)
|
|||
end)
|
||||
|
||||
commander.register('exit', function()
|
||||
bait.throw('hilbish.exit')
|
||||
os.exit(0)
|
||||
end)
|
||||
|
||||
|
|
Loading…
Reference in New Issue