mirror of https://github.com/Hilbis/Hilbish
feat: define lua require paths in var
this makes it able to be changed compile time, which should help in support for systems that dont follow fhs (damn nix) and windows as well, but that'll be first classpull/60/head
parent
2a084fc03e
commit
86dbb97cae
9
lua.go
9
lua.go
|
@ -58,14 +58,7 @@ func LuaInit() {
|
||||||
l.PreloadModule("bait", hooks.Loader)
|
l.PreloadModule("bait", hooks.Loader)
|
||||||
|
|
||||||
// Add more paths that Lua can require from
|
// Add more paths that Lua can require from
|
||||||
l.DoString(`package.path = package.path
|
l.DoString("package.path = package.path .. " + requirePaths)
|
||||||
.. ';./libs/?/init.lua;./?/init.lua;./?/?.lua'
|
|
||||||
.. ';/usr/share/hilbish/libs/?/init.lua;'
|
|
||||||
.. ';/usr/share/hilbish/libs/?/?.lua;'
|
|
||||||
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/init.lua;'
|
|
||||||
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/?.lua;'
|
|
||||||
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?.lua'
|
|
||||||
`)
|
|
||||||
|
|
||||||
err := l.DoFile("preload.lua")
|
err := l.DoFile("preload.lua")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
9
main.go
9
main.go
|
@ -18,26 +18,17 @@ import (
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
version = "v0.4.0"
|
|
||||||
l *lua.LState
|
l *lua.LState
|
||||||
lr *LineReader
|
lr *LineReader
|
||||||
|
|
||||||
prompt string // User's prompt, this will get set when lua side is initialized
|
|
||||||
multilinePrompt = "> "
|
|
||||||
|
|
||||||
commands = map[string]bool{}
|
commands = map[string]bool{}
|
||||||
aliases = map[string]string{}
|
aliases = map[string]string{}
|
||||||
|
|
||||||
homedir string
|
homedir string
|
||||||
curuser *user.User
|
curuser *user.User
|
||||||
|
|
||||||
running bool // Is a command currently running
|
|
||||||
hooks bait.Bait
|
hooks bait.Bait
|
||||||
interactive bool
|
|
||||||
login bool // Are we the login shell?
|
|
||||||
noexecute bool // Should we run Lua or only report syntax errors
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// String vars that are free to be changed at compile time
|
||||||
|
var (
|
||||||
|
version = "v0.4.0"
|
||||||
|
requirePaths = `';./libs/?/init.lua;./?/init.lua;./?/?.lua'
|
||||||
|
.. ';/usr/share/hilbish/libs/?/init.lua;'
|
||||||
|
.. ';/usr/share/hilbish/libs/?/?.lua;'
|
||||||
|
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/init.lua;'
|
||||||
|
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/?.lua;'
|
||||||
|
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?.lua'`
|
||||||
|
|
||||||
|
prompt string // Prompt will always get changed anyway
|
||||||
|
multilinePrompt = "> "
|
||||||
|
)
|
||||||
|
|
||||||
|
// Flags
|
||||||
|
var (
|
||||||
|
running bool // Is a command currently running
|
||||||
|
interactive bool
|
||||||
|
login bool // Are we the login shell?
|
||||||
|
noexecute bool // Should we run Lua or only report syntax errors
|
||||||
|
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue