mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "885c54ed3fd4c7ef583dd3250d1786411199ed02" and "3c4351a8fe25de0683bc6c3b6216071ea027aac9" have entirely different histories.
885c54ed3f
...
3c4351a8fe
|
@ -18,3 +18,4 @@ bait.catch('command.exit', function(code)
|
|||
doPrompt(code ~= 0)
|
||||
end)
|
||||
|
||||
--hook("tab complete", function ())
|
||||
|
|
3
lua.go
3
lua.go
|
@ -53,8 +53,7 @@ func LuaInit(confpath string) {
|
|||
.. ';./libs/?/init.lua;./?/init.lua;./?/?.lua'
|
||||
.. ';/usr/share/hilbish/libs/?/init.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'
|
||||
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/?.lua'
|
||||
`)
|
||||
|
||||
err := l.DoFile("/usr/share/hilbish/preload.lua")
|
||||
|
|
29
main.go
29
main.go
|
@ -4,8 +4,10 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"syscall"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"bufio"
|
||||
"io"
|
||||
hooks "hilbish/golibs/bait"
|
||||
|
||||
|
@ -15,7 +17,7 @@ import (
|
|||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
const version = "0.3.2"
|
||||
const version = "0.3.1"
|
||||
var l *lua.LState
|
||||
// User's prompt, this will get set when lua side is initialized
|
||||
var prompt string
|
||||
|
@ -27,7 +29,6 @@ var commands = map[string]bool{}
|
|||
var aliases = map[string]string{}
|
||||
var bait hooks.Bait
|
||||
var homedir string
|
||||
var running bool
|
||||
|
||||
func main() {
|
||||
homedir, _ = os.UserHomeDir()
|
||||
|
@ -88,14 +89,13 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
go HandleSignals()
|
||||
HandleSignals()
|
||||
LuaInit(*configflag)
|
||||
|
||||
readline.Completer = readline.FilenameCompleter
|
||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||
|
||||
for {
|
||||
running = false
|
||||
input, err := readline.String(fmtPrompt())
|
||||
if err == io.EOF {
|
||||
// Exit if user presses ^D (ctrl + d)
|
||||
|
@ -117,7 +117,6 @@ func main() {
|
|||
if err != nil || !strings.HasSuffix(input, "\\") { break }
|
||||
}
|
||||
}
|
||||
running = true
|
||||
RunInput(input)
|
||||
|
||||
termwidth, _, err := term.GetSize(0)
|
||||
|
@ -127,7 +126,12 @@ func main() {
|
|||
}
|
||||
|
||||
func ContinuePrompt(prev string) (string, error) {
|
||||
cont, err := readline.String(multilinePrompt)
|
||||
fmt.Print(multilinePrompt)
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
// TODO: use readline here?
|
||||
cont, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
fmt.Println("")
|
||||
return "", err
|
||||
|
@ -166,14 +170,9 @@ func fmtPrompt() string {
|
|||
// do i even have to say
|
||||
func HandleSignals() {
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
|
||||
for range c {
|
||||
if !running {
|
||||
fmt.Println(" // interrupt")
|
||||
readline.ReplaceLine("", 0)
|
||||
readline.RefreshLine()
|
||||
}
|
||||
}
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue