mirror of
https://github.com/Hilbis/Hilbish
synced 2025-07-05 02:32:01 +00:00
Compare commits
No commits in common. "aec17d1077a7893b992e63c3d874195fde55f7bb" and "35272ce1acf15cc799f86d4d7bb88901c209b437" have entirely different histories.
aec17d1077
...
35272ce1ac
@ -96,23 +96,12 @@ func fcd(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||
return nil, err
|
||||
}
|
||||
path = util.ExpandHome(strings.TrimSpace(path))
|
||||
oldWd, _ := os.Getwd()
|
||||
|
||||
abspath, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = os.Chdir(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
util.DoString(t.Runtime, fmt.Sprintf(`
|
||||
local bait = require 'bait'
|
||||
bait.throw('hilbish.cd', '%s', '%s')
|
||||
`, abspath, oldWd))
|
||||
|
||||
return c.Next(), err
|
||||
}
|
||||
|
||||
|
16
lua.go
16
lua.go
@ -30,11 +30,19 @@ func luaInit() {
|
||||
// yes this is stupid, i know
|
||||
util.DoString(l, "hilbish = require 'hilbish'")
|
||||
|
||||
lib.LoadLibs(l, fs.Loader)
|
||||
lib.LoadLibs(l, terminal.Loader)
|
||||
lib.LoadLibs(l, snail.Loader)
|
||||
|
||||
cmds = commander.New(l)
|
||||
lib.LoadLibs(l, cmds.Loader)
|
||||
|
||||
hooks = bait.New(l)
|
||||
hooks.SetRecoverer(func(event string, handler *bait.Listener, err interface{}) {
|
||||
fmt.Println("Error in `error` hook handler:", err)
|
||||
hooks.Off(event, handler)
|
||||
})
|
||||
|
||||
lib.LoadLibs(l, hooks.Loader)
|
||||
|
||||
// Add Ctrl-C handler
|
||||
@ -49,14 +57,6 @@ func luaInit() {
|
||||
hooks.Emit("hilbish.rawInput", string(r))
|
||||
}
|
||||
|
||||
lib.LoadLibs(l, fs.Loader)
|
||||
lib.LoadLibs(l, terminal.Loader)
|
||||
lib.LoadLibs(l, snail.Loader)
|
||||
|
||||
cmds = commander.New(l)
|
||||
lib.LoadLibs(l, cmds.Loader)
|
||||
|
||||
|
||||
// Add more paths that Lua can require from
|
||||
_, err := util.DoString(l, "package.path = package.path .. " + requirePaths)
|
||||
if err != nil {
|
||||
|
@ -25,4 +25,5 @@ commander.register('cd', function (args, sinks)
|
||||
end
|
||||
|
||||
bait.throw('cd', path, oldPath)
|
||||
bait.throw('hilbish.cd', absPath, oldPath)
|
||||
end)
|
||||
|
@ -3,7 +3,6 @@ local bait = require 'bait'
|
||||
local snail = require 'snail'
|
||||
|
||||
hilbish.snail = snail.new()
|
||||
hilbish.snail:run 'true' -- to "initialize" snail
|
||||
bait.catch('hilbish.cd', function(path)
|
||||
hilbish.snail:dir(path)
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user