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 = `
|
||||
ansikit = require 'ansikit'
|
||||
prompt(ansikit.format(
|
||||
lunacolors = require 'lunacolors'
|
||||
prompt(lunacolors.format(
|
||||
'{blue}%u {cyan}%d {green}∆{reset} '
|
||||
))
|
||||
`
|
||||
|
@ -58,18 +58,11 @@ func LuaInit() {
|
|||
l.PreloadModule("bait", hooks.Loader)
|
||||
|
||||
// Add more paths that Lua can require from
|
||||
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'
|
||||
`)
|
||||
l.DoString("package.path = package.path .. " + requirePaths)
|
||||
|
||||
err := l.DoFile("preload.lua")
|
||||
if err != nil {
|
||||
err = l.DoFile("/usr/share/hilbish/preload.lua")
|
||||
err = l.DoFile(preloadPath)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr,
|
||||
"Missing preload file, builtins may be missing.")
|
||||
|
@ -83,7 +76,7 @@ func RunConfig(confpath string) {
|
|||
err := l.DoFile(confpath)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
|
12
main.go
12
main.go
|
@ -18,26 +18,17 @@ import (
|
|||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
|
||||
var (
|
||||
version = "v0.4.0"
|
||||
l *lua.LState
|
||||
lr *LineReader
|
||||
|
||||
prompt string // User's prompt, this will get set when lua side is initialized
|
||||
multilinePrompt = "> "
|
||||
|
||||
commands = map[string]bool{}
|
||||
aliases = map[string]string{}
|
||||
|
||||
homedir string
|
||||
curuser *user.User
|
||||
|
||||
running bool // Is a command currently running
|
||||
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() {
|
||||
|
@ -227,8 +218,7 @@ func HandleSignals() {
|
|||
|
||||
for range c {
|
||||
if !running {
|
||||
//readline.ReplaceLine("", 0)
|
||||
//readline.RefreshLine()
|
||||
lr.ClearInput()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
5
rl.go
5
rl.go
|
@ -34,3 +34,8 @@ func (lr *LineReader) AddHistory(cmd string) {
|
|||
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
|
||||
}
|
||||
|
||||
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