mirror of https://github.com/Hilbis/Hilbish
Compare commits
22 Commits
08c56a54ca
...
926fc96895
Author | SHA1 | Date |
---|---|---|
sammy | 926fc96895 | |
sammy | d4ecdd5ea0 | |
sammy | 3862d2898c | |
sammy | d9c05e485d | |
sammy | 5d0fecf902 | |
sammy | 935bed3dc6 | |
sammy | 17e12c8c2a | |
sammy | bdc8c770e6 | |
sammy | 7b0b06d9bf | |
sammy | 050165d7b1 | |
sammy | aa5b68ec2b | |
sammy | 55c05a9a92 | |
sammy | 53adc6ab21 | |
sammy | 2f8cb200ba | |
sammy | b37f2411c7 | |
sammy | e32639800e | |
sammy | 7193c20e99 | |
sammy | 98ff54a4f4 | |
sammy | 385b59bfda | |
sammy | 5e44b84272 | |
sammy | e2c775a89d | |
sammy | 2089d71ed2 |
12
README.md
12
README.md
|
@ -10,8 +10,8 @@
|
|||
|
||||
Hilbish is an interactive Unix-like shell written in Go, with the config
|
||||
and other code written in Lua.
|
||||
It is currently in a Beta state. Though very fit for daily usage,
|
||||
updates may contain breaking changes.
|
||||
It is sort of in a stable state currently, usable as a daily shell,
|
||||
but there may still be breaking changes in Lua modules.
|
||||
|
||||
# Screenshots
|
||||
<div align="center">
|
||||
|
@ -57,12 +57,12 @@ sudo make all
|
|||
|
||||
Alternativly, if you use Arch Linux, you can compile Hilbish with an **(unofficial)** AUR package
|
||||
```sh
|
||||
yay -S hilbish-git
|
||||
```
|
||||
Or install a prebuilt binary from an **(unofficial)** AUR package
|
||||
```sh
|
||||
yay -S hilbish
|
||||
```
|
||||
If you want the latest and greatest, you can install and compile from latest git commit
|
||||
```sh
|
||||
yay -S hilbish-git
|
||||
```
|
||||
|
||||
### Uninstall
|
||||
```sh
|
||||
|
|
9
go.mod
9
go.mod
|
@ -3,16 +3,15 @@ module hilbish
|
|||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/Nerdmaster/terminal v0.12.1 // indirect
|
||||
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/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807 // indirect
|
||||
github.com/gdamore/tcell v1.4.0 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 // indirect
|
||||
golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 // indirect
|
||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect
|
||||
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72
|
||||
layeh.com/gopher-luar v1.0.8
|
||||
mvdan.cc/sh/v3 v3.2.4
|
||||
)
|
||||
|
|
36
go.sum
36
go.sum
|
@ -1,5 +1,5 @@
|
|||
github.com/Nerdmaster/terminal v0.12.1 h1:DGb3ya55nZdqdBMjWQHNF5mHYHS2eJgYLqmw3KnE1cQ=
|
||||
github.com/Nerdmaster/terminal v0.12.1/go.mod h1:Dg6++m3aF+P/l8RdYb/2N6zK3CqvUfzhBreUNEWuQ8M=
|
||||
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4 h1:S9ulYwm5MUp02mEKnbDhVGjVBkdYV7/tmgEO1g3Q+Z8=
|
||||
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=
|
||||
|
@ -9,25 +9,23 @@ github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2w
|
|||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
|
||||
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807 h1:jdjd5e68T4R/j4PWxfZqcKY8KtT9oo8IPNVuV4bSXDQ=
|
||||
github.com/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807/go.mod h1:Xoiu5VdKMvbRgHuY7+z64lhu/7lvax/22nzASF6GrO8=
|
||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
|
||||
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
@ -39,19 +37,15 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d h1:jbzgAvDZn8aEnytae+4ou0J0GwFZoHR0hOrTg4qH8GA=
|
||||
golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg=
|
||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4=
|
||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 h1:EC6+IGYTjPpRfv9a2b/6Puw0W+hLtAhkV1tPsXhutqs=
|
||||
golang.org/x/term v0.0.0-20210317153231-de623e64d2a6/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 h1:VqE9gduFZ4dbR7XoL77lHFp0/DyDUBKSXK7CMFkVcV0=
|
||||
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
|
|
1
lua.go
1
lua.go
|
@ -67,6 +67,7 @@ func LuaInit(confpath string) {
|
|||
}
|
||||
|
||||
// Run config
|
||||
if !interactive { return }
|
||||
err = l.DoFile(confpath)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err,
|
||||
|
|
36
main.go
36
main.go
|
@ -16,7 +16,7 @@ import (
|
|||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
const version = "0.3.2"
|
||||
const version = "0.4.0-dev.3"
|
||||
|
||||
var (
|
||||
l *lua.LState
|
||||
|
@ -31,6 +31,7 @@ var (
|
|||
bait hooks.Bait
|
||||
homedir string
|
||||
running bool
|
||||
interactive bool
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -46,11 +47,25 @@ 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",
|
||||
Default: defaultconfpath,
|
||||
})
|
||||
// loginshflag
|
||||
// TODO: issue #37
|
||||
_ = parser.Flag("l", "login", &argparse.Options{
|
||||
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,
|
||||
|
@ -60,6 +75,10 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
if *cmdflag == "" || *interactiveflag {
|
||||
interactive = true
|
||||
}
|
||||
|
||||
if *verflag {
|
||||
fmt.Printf("Hilbish v%s\n", version)
|
||||
os.Exit(0)
|
||||
|
@ -85,7 +104,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")
|
||||
|
@ -100,9 +119,12 @@ func main() {
|
|||
readline.Completer = readline.FilenameCompleter
|
||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||
|
||||
for {
|
||||
RunInput(*cmdflag)
|
||||
for interactive {
|
||||
running = false
|
||||
|
||||
input, err := readline.String(fmtPrompt())
|
||||
|
||||
if err == io.EOF {
|
||||
// Exit if user presses ^D (ctrl + d)
|
||||
fmt.Println("")
|
||||
|
@ -114,9 +136,7 @@ func main() {
|
|||
}
|
||||
|
||||
input = strings.TrimSpace(input)
|
||||
if len(input) == 0 {
|
||||
continue
|
||||
}
|
||||
if len(input) == 0 { continue }
|
||||
|
||||
if strings.HasSuffix(input, "\\") {
|
||||
for {
|
||||
|
@ -134,7 +154,7 @@ 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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +166,7 @@ func ContinuePrompt(prev string) (string, error) {
|
|||
}
|
||||
cont = strings.TrimSpace(cont)
|
||||
|
||||
return prev + "\n" + strings.TrimSuffix(cont, "\n"), nil
|
||||
return prev + " " + strings.TrimSuffix(cont, "\n"), nil
|
||||
}
|
||||
|
||||
// This semi cursed function formats our prompt (obviously)
|
||||
|
|
11
shell.go
11
shell.go
|
@ -8,8 +8,8 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/bobappleyard/readline"
|
||||
"github.com/yuin/gopher-lua"
|
||||
"github.com/bobappleyard/readline"
|
||||
"layeh.com/gopher-luar"
|
||||
"mvdan.cc/sh/v3/interp"
|
||||
"mvdan.cc/sh/v3/syntax"
|
||||
|
@ -31,7 +31,9 @@ func RunInput(input string) {
|
|||
|
||||
// If alias was found, use command alias
|
||||
if aliases[cmdArgs[0]] != "" {
|
||||
cmdString = aliases[cmdArgs[0]] + strings.Trim(cmdString, cmdArgs[0])
|
||||
alias := aliases[cmdArgs[0]]
|
||||
cmdString = alias + strings.Trim(cmdString, cmdArgs[0])
|
||||
cmdArgs[0] = alias
|
||||
}
|
||||
|
||||
// If command is defined in Lua then run it
|
||||
|
@ -165,15 +167,14 @@ func HandleHistory(cmd string) {
|
|||
func StartMultiline(prev string, sb *strings.Builder) bool {
|
||||
// sb fromt outside is passed so we can
|
||||
// save input from previous prompts
|
||||
if sb.String() == "" {
|
||||
sb.WriteString(prev + "\n")
|
||||
}
|
||||
if sb.String() == "" { sb.WriteString(prev + " ") }
|
||||
|
||||
fmt.Print(multilinePrompt)
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
cont, err := reader.ReadString('\n')
|
||||
cont = strings.TrimSuffix(cont, "\n") + " "
|
||||
if err == io.EOF {
|
||||
// Exit when ^D
|
||||
fmt.Println("")
|
||||
|
|
Loading…
Reference in New Issue