Compare commits

..

6 Commits

Author SHA1 Message Date
sammy 1868715b8a chore: merge from master 2021-04-09 20:00:53 -04:00
sammy b38585e86d chore: update .gitignore 2021-04-09 18:22:28 -04:00
sammy 3523bfa28b feat: add more paths to package.path 2021-04-09 18:22:05 -04:00
TorchedSammy 2c711de9dc feat: add mkdir and stat functions to fs module 2021-04-09 18:10:18 -04:00
TorchedSammy 34a652c8bd chore: remove todo file 2021-04-08 14:56:16 -04:00
TorchedSammy f02b6528e8 docs: add badges 2021-04-08 14:55:37 -04:00
5 changed files with 30 additions and 12 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
hilbish hilbish
.vim .vim
petals/

View File

@ -2,7 +2,10 @@
<h1>Hilbish</h1> <h1>Hilbish</h1>
<blockquote> <blockquote>
🎀 a nice lil shell for lua people made with go and lua 🎀 a nice lil shell for lua people made with go and lua
</blockquote> </blockquote><p align="center">
<a href="https://github.com/Hilbis/Hilbish/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22"><img src="https://img.shields.io/github/issues/Hilbis/Hilbish/help%20wanted?color=green" alt="help wanted"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
</p>
</div> </div>
Hilbish is an interactive Unix-like shell written in Go, with the config Hilbish is an interactive Unix-like shell written in Go, with the config

10
TODO.md
View File

@ -1,10 +0,0 @@
- [x] Configuration
- [x] Make default config if missing
- [x] Tab completion
- [x] Custom commands via the shell
- [ ] Confirmed windows support
- [ ] Readme badges
- [x] Hooks
- [x] Aliases
- [ ] hlua (hilbish lua) - 100% lua in the hilbish interactive shell, cuz why not
- [ ] Petals (name of plugins)

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
"github.com/yuin/gopher-lua" "github.com/yuin/gopher-lua"
"layeh.com/gopher-luar"
) )
func Loader(L *lua.LState) int { func Loader(L *lua.LState) int {
@ -22,6 +23,8 @@ func LuaErr(L *lua.LState, code int) {
var exports = map[string]lua.LGFunction{ var exports = map[string]lua.LGFunction{
"cd": cd, "cd": cd,
"mkdir": mkdir,
"stat": stat,
} }
func cd(L *lua.LState) int { func cd(L *lua.LState) int {
@ -38,3 +41,21 @@ func cd(L *lua.LState) int {
return 0 return 0
} }
func mkdir(L *lua.LState) int {
dirname := L.ToString(1)
// TODO: handle error here
os.Mkdir(strings.TrimSpace(dirname), 0744)
return 0
}
func stat(L *lua.LState) int {
path := L.ToString(1)
// TODO: handle error here
pathinfo, _ := os.Stat(path)
L.Push(luar.New(L, pathinfo))
return 1
}

5
lua.go
View File

@ -49,7 +49,10 @@ func LuaInit(confpath string) {
l.PreloadModule("bait", bait.Loader) l.PreloadModule("bait", bait.Loader)
// Add more paths that Lua can require from // Add more paths that Lua can require from
l.DoString("package.path = package.path .. ';./libs/?/init.lua;/usr/share/hilbish/libs/?/init.lua'") l.DoString(`package.path = package.path
.. ';./libs/?/init.lua;/usr/share/hilbish/libs/?/init.lua'
.. ';./?/init.lua;./?/?.lua'
`)
err := l.DoFile("/usr/share/hilbish/preload.lua") err := l.DoFile("/usr/share/hilbish/preload.lua")
if err != nil { if err != nil {