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 (
|
require (
|
||||||
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4
|
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4
|
||||||
github.com/akamensky/argparse v1.2.2
|
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/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
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/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 h1:P17T0ZjlUNJuWTPPJ2A5dM1wxarHgHqfYH+AZTo2xQA=
|
||||||
github.com/akamensky/argparse v1.2.2/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
|
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 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2wSM9zJkl1UQEFZgSd68NfCgRz1VL1jzy/RjCg+ULrs=
|
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=
|
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
|
// Run config
|
||||||
if !interactive { return }
|
|
||||||
err = l.DoFile(confpath)
|
err = l.DoFile(confpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err,
|
fmt.Fprintln(os.Stderr, err,
|
||||||
|
|
39
main.go
39
main.go
|
@ -11,12 +11,12 @@ import (
|
||||||
hooks "hilbish/golibs/bait"
|
hooks "hilbish/golibs/bait"
|
||||||
|
|
||||||
"github.com/akamensky/argparse"
|
"github.com/akamensky/argparse"
|
||||||
"github.com/bobappleyard/readline"
|
"github.com/Hilbis/Hilbiline"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.4.0-dev.3"
|
const version = "0.4.0-dev.2+hilbiline"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
l *lua.LState
|
l *lua.LState
|
||||||
|
@ -31,7 +31,6 @@ var (
|
||||||
bait hooks.Bait
|
bait hooks.Bait
|
||||||
homedir string
|
homedir string
|
||||||
running bool
|
running bool
|
||||||
interactive bool
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -47,10 +46,6 @@ func main() {
|
||||||
Required: false,
|
Required: false,
|
||||||
Help: "Sets $SHELL to Hilbish's executed path",
|
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{
|
configflag := parser.String("C", "config", &argparse.Options{
|
||||||
Required: false,
|
Required: false,
|
||||||
Help: "Sets the path to Hilbish's config",
|
Help: "Sets the path to Hilbish's config",
|
||||||
|
@ -62,10 +57,7 @@ func main() {
|
||||||
Required: false,
|
Required: false,
|
||||||
Help: "Makes Hilbish act like a login shell",
|
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)
|
err := parser.Parse(os.Args)
|
||||||
// If invalid flags or --help/-h,
|
// If invalid flags or --help/-h,
|
||||||
|
@ -75,10 +67,6 @@ func main() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *cmdflag == "" || *interactiveflag {
|
|
||||||
interactive = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if *verflag {
|
if *verflag {
|
||||||
fmt.Printf("Hilbish v%s\n", version)
|
fmt.Printf("Hilbish v%s\n", version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -116,14 +104,15 @@ func main() {
|
||||||
go HandleSignals()
|
go HandleSignals()
|
||||||
LuaInit(*configflag)
|
LuaInit(*configflag)
|
||||||
|
|
||||||
readline.Completer = readline.FilenameCompleter
|
hl := hilbiline.New("")
|
||||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
//readline.Completer = readline.FilenameCompleter
|
||||||
|
//readline.LoadHistory(homedir + "/.hilbish-history")
|
||||||
|
|
||||||
RunInput(*cmdflag)
|
for {
|
||||||
for interactive {
|
|
||||||
running = false
|
running = false
|
||||||
|
|
||||||
input, err := readline.String(fmtPrompt())
|
hl.SetPrompt(fmtPrompt())
|
||||||
|
input, err := hl.Read()
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
// Exit if user presses ^D (ctrl + d)
|
// Exit if user presses ^D (ctrl + d)
|
||||||
|
@ -136,7 +125,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
input = strings.TrimSpace(input)
|
input = strings.TrimSpace(input)
|
||||||
if len(input) == 0 { continue }
|
if len(input) == 0 { fmt.Print("\n"); continue }
|
||||||
|
|
||||||
if strings.HasSuffix(input, "\\") {
|
if strings.HasSuffix(input, "\\") {
|
||||||
for {
|
for {
|
||||||
|
@ -159,7 +148,8 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContinuePrompt(prev string) (string, error) {
|
func ContinuePrompt(prev string) (string, error) {
|
||||||
cont, err := readline.String(multilinePrompt)
|
hl := hilbiline.New(multilinePrompt)
|
||||||
|
cont, err := hl.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -202,8 +192,9 @@ func HandleSignals() {
|
||||||
|
|
||||||
for range c {
|
for range c {
|
||||||
if !running {
|
if !running {
|
||||||
readline.ReplaceLine("", 0)
|
//fmt.Println(" // interrupt")
|
||||||
readline.RefreshLine()
|
//readline.ReplaceLine("", 0)
|
||||||
|
//readline.RefreshLine()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
shell.go
7
shell.go
|
@ -9,7 +9,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"github.com/bobappleyard/readline"
|
|
||||||
"layeh.com/gopher-luar"
|
"layeh.com/gopher-luar"
|
||||||
"mvdan.cc/sh/v3/interp"
|
"mvdan.cc/sh/v3/interp"
|
||||||
"mvdan.cc/sh/v3/syntax"
|
"mvdan.cc/sh/v3/syntax"
|
||||||
|
@ -114,7 +113,7 @@ func splitInput(input string) ([]string, string) {
|
||||||
cmdArgs := []string{}
|
cmdArgs := []string{}
|
||||||
sb := &strings.Builder{}
|
sb := &strings.Builder{}
|
||||||
cmdstr := &strings.Builder{}
|
cmdstr := &strings.Builder{}
|
||||||
lastcmd := readline.GetHistory(readline.HistorySize() - 1)
|
lastcmd := "" //readline.GetHistory(readline.HistorySize() - 1)
|
||||||
|
|
||||||
for _, r := range input {
|
for _, r := range input {
|
||||||
if r == '"' {
|
if r == '"' {
|
||||||
|
@ -159,8 +158,8 @@ func splitInput(input string) ([]string, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleHistory(cmd string) {
|
func HandleHistory(cmd string) {
|
||||||
readline.AddHistory(cmd)
|
//readline.AddHistory(cmd)
|
||||||
readline.SaveHistory(homedir + "/.hilbish-history")
|
//readline.SaveHistory(homedir + "/.hilbish-history")
|
||||||
// TODO: load history again (history shared between sessions like this ye)
|
// TODO: load history again (history shared between sessions like this ye)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue