mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "d4ecdd5ea0f3d320915bb8298d4454faf68ef297" and "17e12c8c2a93d0955c84cb417fd7660facbed678" have entirely different histories.
d4ecdd5ea0
...
17e12c8c2a
1
go.mod
1
go.mod
|
@ -5,7 +5,6 @@ go 1.16
|
|||
require (
|
||||
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4
|
||||
github.com/akamensky/argparse v1.2.2
|
||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e
|
||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
||||
|
|
2
go.sum
2
go.sum
|
@ -2,8 +2,6 @@ github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4 h1:S9ulYwm5MUp02m
|
|||
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4/go.mod h1:mp9I7lvFoZ3ldAeydCzISakl6VdQYyrR8vVjmnKGqDo=
|
||||
github.com/akamensky/argparse v1.2.2 h1:P17T0ZjlUNJuWTPPJ2A5dM1wxarHgHqfYH+AZTo2xQA=
|
||||
github.com/akamensky/argparse v1.2.2/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
|
||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e h1:4G8AYOOwZdDWOiJR6D6JXaFmj5BDS7c5D5PyqsG/+Hg=
|
||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e/go.mod h1:fmqtV+Wqx0uFYLN1F4VhjZdtT56Dr8c3yA7nALFsw/Q=
|
||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2wSM9zJkl1UQEFZgSd68NfCgRz1VL1jzy/RjCg+ULrs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
|
|
1
lua.go
1
lua.go
|
@ -67,7 +67,6 @@ func LuaInit(confpath string) {
|
|||
}
|
||||
|
||||
// Run config
|
||||
if !interactive { return }
|
||||
err = l.DoFile(confpath)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err,
|
||||
|
|
43
main.go
43
main.go
|
@ -11,12 +11,12 @@ import (
|
|||
hooks "hilbish/golibs/bait"
|
||||
|
||||
"github.com/akamensky/argparse"
|
||||
"github.com/bobappleyard/readline"
|
||||
"github.com/Hilbis/Hilbiline"
|
||||
"github.com/yuin/gopher-lua"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
const version = "0.4.0-dev.3"
|
||||
const version = "0.4.0-dev.2+hilbiline"
|
||||
|
||||
var (
|
||||
l *lua.LState
|
||||
|
@ -31,7 +31,6 @@ var (
|
|||
bait hooks.Bait
|
||||
homedir string
|
||||
running bool
|
||||
interactive bool
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -47,10 +46,6 @@ func main() {
|
|||
Required: false,
|
||||
Help: "Sets $SHELL to Hilbish's executed path",
|
||||
})
|
||||
cmdflag := parser.String("c", "command", &argparse.Options{
|
||||
Required: false,
|
||||
// TODO: Help: "",
|
||||
})
|
||||
configflag := parser.String("C", "config", &argparse.Options{
|
||||
Required: false,
|
||||
Help: "Sets the path to Hilbish's config",
|
||||
|
@ -62,10 +57,7 @@ func main() {
|
|||
Required: false,
|
||||
Help: "Makes Hilbish act like a login shell",
|
||||
})
|
||||
interactiveflag := parser.Flag("i", "interactive", &argparse.Options{
|
||||
Required: false,
|
||||
Help: "Force Hilbish to be an interactive shell",
|
||||
})
|
||||
|
||||
|
||||
err := parser.Parse(os.Args)
|
||||
// If invalid flags or --help/-h,
|
||||
|
@ -75,10 +67,6 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
if *cmdflag == "" || *interactiveflag {
|
||||
interactive = true
|
||||
}
|
||||
|
||||
if *verflag {
|
||||
fmt.Printf("Hilbish v%s\n", version)
|
||||
os.Exit(0)
|
||||
|
@ -104,7 +92,7 @@ func main() {
|
|||
}
|
||||
|
||||
// Create it using either default config we found
|
||||
err = os.WriteFile(homedir + "/.hilbishrc.lua", input, 0644)
|
||||
err = os.WriteFile(homedir+"/.hilbishrc.lua", input, 0644)
|
||||
if err != nil {
|
||||
// If that fails, bail
|
||||
fmt.Println("Error creating config file")
|
||||
|
@ -116,14 +104,15 @@ func main() {
|
|||
go HandleSignals()
|
||||
LuaInit(*configflag)
|
||||
|
||||
readline.Completer = readline.FilenameCompleter
|
||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||
hl := hilbiline.New("")
|
||||
//readline.Completer = readline.FilenameCompleter
|
||||
//readline.LoadHistory(homedir + "/.hilbish-history")
|
||||
|
||||
RunInput(*cmdflag)
|
||||
for interactive {
|
||||
for {
|
||||
running = false
|
||||
|
||||
input, err := readline.String(fmtPrompt())
|
||||
hl.SetPrompt(fmtPrompt())
|
||||
input, err := hl.Read()
|
||||
|
||||
if err == io.EOF {
|
||||
// Exit if user presses ^D (ctrl + d)
|
||||
|
@ -136,7 +125,7 @@ func main() {
|
|||
}
|
||||
|
||||
input = strings.TrimSpace(input)
|
||||
if len(input) == 0 { continue }
|
||||
if len(input) == 0 { fmt.Print("\n"); continue }
|
||||
|
||||
if strings.HasSuffix(input, "\\") {
|
||||
for {
|
||||
|
@ -154,12 +143,13 @@ func main() {
|
|||
if err != nil {
|
||||
continue
|
||||
}
|
||||
fmt.Printf("\u001b[7m∆\u001b[0m" + strings.Repeat(" ", termwidth - 1) + "\r")
|
||||
fmt.Printf("\u001b[7m∆\u001b[0m" + strings.Repeat(" ", termwidth-1) + "\r")
|
||||
}
|
||||
}
|
||||
|
||||
func ContinuePrompt(prev string) (string, error) {
|
||||
cont, err := readline.String(multilinePrompt)
|
||||
hl := hilbiline.New(multilinePrompt)
|
||||
cont, err := hl.Read()
|
||||
if err != nil {
|
||||
fmt.Println("")
|
||||
return "", err
|
||||
|
@ -202,8 +192,9 @@ func HandleSignals() {
|
|||
|
||||
for range c {
|
||||
if !running {
|
||||
readline.ReplaceLine("", 0)
|
||||
readline.RefreshLine()
|
||||
//fmt.Println(" // interrupt")
|
||||
//readline.ReplaceLine("", 0)
|
||||
//readline.RefreshLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
7
shell.go
7
shell.go
|
@ -9,7 +9,6 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/yuin/gopher-lua"
|
||||
"github.com/bobappleyard/readline"
|
||||
"layeh.com/gopher-luar"
|
||||
"mvdan.cc/sh/v3/interp"
|
||||
"mvdan.cc/sh/v3/syntax"
|
||||
|
@ -114,7 +113,7 @@ func splitInput(input string) ([]string, string) {
|
|||
cmdArgs := []string{}
|
||||
sb := &strings.Builder{}
|
||||
cmdstr := &strings.Builder{}
|
||||
lastcmd := readline.GetHistory(readline.HistorySize() - 1)
|
||||
lastcmd := "" //readline.GetHistory(readline.HistorySize() - 1)
|
||||
|
||||
for _, r := range input {
|
||||
if r == '"' {
|
||||
|
@ -159,8 +158,8 @@ func splitInput(input string) ([]string, string) {
|
|||
}
|
||||
|
||||
func HandleHistory(cmd string) {
|
||||
readline.AddHistory(cmd)
|
||||
readline.SaveHistory(homedir + "/.hilbish-history")
|
||||
//readline.AddHistory(cmd)
|
||||
//readline.SaveHistory(homedir + "/.hilbish-history")
|
||||
// TODO: load history again (history shared between sessions like this ye)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue