mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "e37abcb08b0c1f576d981e134797f66943c84ecb" and "f0013096fdf025afdebcf1903540da4a1b748d71" have entirely different histories.
e37abcb08b
...
f0013096fd
17
lua.go
17
lua.go
|
@ -16,8 +16,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var minimalconf = `
|
var minimalconf = `
|
||||||
lunacolors = require 'lunacolors'
|
ansikit = require 'ansikit'
|
||||||
prompt(lunacolors.format(
|
prompt(ansikit.format(
|
||||||
'{blue}%u {cyan}%d {green}∆{reset} '
|
'{blue}%u {cyan}%d {green}∆{reset} '
|
||||||
))
|
))
|
||||||
`
|
`
|
||||||
|
@ -58,11 +58,18 @@ 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 .. " + requirePaths)
|
l.DoString(`package.path = package.path
|
||||||
|
.. ';./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 {
|
||||||
err = l.DoFile(preloadPath)
|
err = l.DoFile("/usr/share/hilbish/preload.lua")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprintln(os.Stderr,
|
||||||
"Missing preload file, builtins may be missing.")
|
"Missing preload file, builtins may be missing.")
|
||||||
|
@ -76,7 +83,7 @@ func RunConfig(confpath string) {
|
||||||
err := l.DoFile(confpath)
|
err := l.DoFile(confpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err,
|
fmt.Fprintln(os.Stderr, err,
|
||||||
"\nAn error has occured while loading your config! Falling back to minimal default config.")
|
"\nAn error has occured while loading your config! Falling back to minimal default config.\n")
|
||||||
|
|
||||||
l.DoString(minimalconf)
|
l.DoString(minimalconf)
|
||||||
}
|
}
|
||||||
|
|
12
main.go
12
main.go
|
@ -18,17 +18,26 @@ 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() {
|
||||||
|
@ -218,7 +227,8 @@ func HandleSignals() {
|
||||||
|
|
||||||
for range c {
|
for range c {
|
||||||
if !running {
|
if !running {
|
||||||
lr.ClearInput()
|
//readline.ReplaceLine("", 0)
|
||||||
|
//readline.RefreshLine()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
rl.go
5
rl.go
|
@ -34,8 +34,3 @@ func (lr *LineReader) AddHistory(cmd string) {
|
||||||
readline.SaveHistory(homedir + "/.hilbish-history")
|
readline.SaveHistory(homedir + "/.hilbish-history")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lr *LineReader) ClearInput() {
|
|
||||||
readline.ReplaceLine("", 0)
|
|
||||||
readline.RefreshLine()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,3 @@ func (lr *LineReader) AddHistory(cmd string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lr *LineReader) ClearInput() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
25
vars.go
25
vars.go
|
@ -1,25 +0,0 @@
|
||||||
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'`
|
|
||||||
preloadPath = "/usr/share/hilbish/preload.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