mirror of https://github.com/Hilbis/Hilbish
Compare commits
5 Commits
f0013096fd
...
e37abcb08b
Author | SHA1 | Date |
---|---|---|
sammyette | e37abcb08b | |
sammyette | be5ebd6ada | |
sammyette | 86dbb97cae | |
sammyette | 2a084fc03e | |
sammyette | ef45bafb54 |
17
lua.go
17
lua.go
|
@ -16,8 +16,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var minimalconf = `
|
var minimalconf = `
|
||||||
ansikit = require 'ansikit'
|
lunacolors = require 'lunacolors'
|
||||||
prompt(ansikit.format(
|
prompt(lunacolors.format(
|
||||||
'{blue}%u {cyan}%d {green}∆{reset} '
|
'{blue}%u {cyan}%d {green}∆{reset} '
|
||||||
))
|
))
|
||||||
`
|
`
|
||||||
|
@ -58,18 +58,11 @@ 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 {
|
||||||
err = l.DoFile("/usr/share/hilbish/preload.lua")
|
err = l.DoFile(preloadPath)
|
||||||
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.")
|
||||||
|
@ -83,7 +76,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.\n")
|
"\nAn error has occured while loading your config! Falling back to minimal default config.")
|
||||||
|
|
||||||
l.DoString(minimalconf)
|
l.DoString(minimalconf)
|
||||||
}
|
}
|
||||||
|
|
12
main.go
12
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() {
|
||||||
|
@ -227,8 +218,7 @@ func HandleSignals() {
|
||||||
|
|
||||||
for range c {
|
for range c {
|
||||||
if !running {
|
if !running {
|
||||||
//readline.ReplaceLine("", 0)
|
lr.ClearInput()
|
||||||
//readline.RefreshLine()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
rl.go
5
rl.go
|
@ -34,3 +34,8 @@ 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,3 +32,7 @@ func (lr *LineReader) AddHistory(cmd string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (lr *LineReader) ClearInput() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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'`
|
||||||
|
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