Compare commits

..

22 Commits

Author SHA1 Message Date
sammy 926fc96895
docs: update readme to not say its beta 2021-04-24 18:42:39 -04:00
sammy d4ecdd5ea0
feat: -i (--interactive) and -c (--command) flag 2021-04-24 00:12:18 -04:00
sammy 3862d2898c
chore: update manifests 2021-04-24 00:10:51 -04:00
sammy d9c05e485d
style: spacing between binary op 2021-04-23 23:44:59 -04:00
sammy 5d0fecf902
fix: use readline in continue prompt 2021-04-23 23:44:22 -04:00
sammy 935bed3dc6
fix: switch back to readline for the time being 2021-04-23 23:42:34 -04:00
sammy 17e12c8c2a
chore: merge from master, resolve conflicts 2021-04-20 19:31:19 -04:00
sammy bdc8c770e6
fix: aliases for lua commands 2021-04-20 19:26:33 -04:00
sammy 7b0b06d9bf
fix: dont make continue prompt input include a newline 2021-04-19 22:08:16 -04:00
sammy 050165d7b1
fix: make --login actually a flag 2021-04-18 19:01:55 -04:00
sammy aa5b68ec2b
fix: assign loginshflag to throwaway var 2021-04-18 18:53:22 -04:00
sammy 55c05a9a92
feat: add login flag (todo) 2021-04-18 18:50:18 -04:00
sammy 53adc6ab21
chore: bump verison 2021-04-18 17:48:04 -04:00
sammy 2f8cb200ba
chore: merge from hilbiline branch 2021-04-18 17:44:46 -04:00
sammy b37f2411c7
chore: update manifests 2021-04-18 15:42:39 -04:00
sammy e32639800e
fix: dont use readline at all 2021-04-18 15:41:37 -04:00
sammy 7193c20e99
chore: fix merge conflict 2021-04-16 11:37:22 -04:00
sammy 98ff54a4f4
fix: set prompt to nothing initially 2021-04-16 11:36:23 -04:00
sammy 385b59bfda
chore: bump version 2021-04-16 10:42:44 -04:00
sammy 5e44b84272
chore: update manifest files 2021-04-16 10:28:28 -04:00
sammy e2c775a89d
fix: print newline on ctrlc 2021-04-16 10:27:11 -04:00
sammy 2089d71ed2 feat: switch to hilbiline 2021-04-14 19:55:03 -04:00
6 changed files with 60 additions and 45 deletions

View File

@ -10,8 +10,8 @@
Hilbish is an interactive Unix-like shell written in Go, with the config Hilbish is an interactive Unix-like shell written in Go, with the config
and other code written in Lua. and other code written in Lua.
It is currently in a Beta state. Though very fit for daily usage, It is sort of in a stable state currently, usable as a daily shell,
updates may contain breaking changes. but there may still be breaking changes in Lua modules.
# Screenshots # Screenshots
<div align="center"> <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 Alternativly, if you use Arch Linux, you can compile Hilbish with an **(unofficial)** AUR package
```sh ```sh
yay -S hilbish-git
```
Or install a prebuilt binary from an **(unofficial)** AUR package
```sh
yay -S hilbish 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 ### Uninstall
```sh ```sh

9
go.mod
View File

@ -3,16 +3,15 @@ module hilbish
go 1.16 go 1.16
require ( 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/akamensky/argparse v1.2.2
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e 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/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807 // indirect github.com/rivo/uniseg v0.2.0 // indirect
github.com/gdamore/tcell v1.4.0 // indirect
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 // indirect golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect
golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 // indirect golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72
layeh.com/gopher-luar v1.0.8 layeh.com/gopher-luar v1.0.8
mvdan.cc/sh/v3 v3.2.4 mvdan.cc/sh/v3 v3.2.4
) )

36
go.sum
View File

@ -1,5 +1,5 @@
github.com/Nerdmaster/terminal v0.12.1 h1:DGb3ya55nZdqdBMjWQHNF5mHYHS2eJgYLqmw3KnE1cQ= github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4 h1:S9ulYwm5MUp02mEKnbDhVGjVBkdYV7/tmgEO1g3Q+Z8=
github.com/Nerdmaster/terminal v0.12.1/go.mod h1:Dg6++m3aF+P/l8RdYb/2N6zK3CqvUfzhBreUNEWuQ8M= 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 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/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/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/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/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/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/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.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/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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/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/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
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/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28= 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/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/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/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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 h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-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-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-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-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-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d/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-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg= golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/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-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-20210406210042-72f3dc4e9b72 h1:VqE9gduFZ4dbR7XoL77lHFp0/DyDUBKSXK7CMFkVcV0=
golang.org/x/term v0.0.0-20210317153231-de623e64d2a6/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72/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=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 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/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=

1
lua.go
View File

@ -67,6 +67,7 @@ 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,

36
main.go
View File

@ -16,7 +16,7 @@ import (
"golang.org/x/term" "golang.org/x/term"
) )
const version = "0.3.2" const version = "0.4.0-dev.3"
var ( var (
l *lua.LState l *lua.LState
@ -31,6 +31,7 @@ var (
bait hooks.Bait bait hooks.Bait
homedir string homedir string
running bool running bool
interactive bool
) )
func main() { func main() {
@ -46,11 +47,25 @@ 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",
Default: defaultconfpath, 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) err := parser.Parse(os.Args)
// If invalid flags or --help/-h, // If invalid flags or --help/-h,
@ -60,6 +75,10 @@ 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)
@ -85,7 +104,7 @@ func main() {
} }
// Create it using either default config we found // 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 err != nil {
// If that fails, bail // If that fails, bail
fmt.Println("Error creating config file") fmt.Println("Error creating config file")
@ -100,9 +119,12 @@ func main() {
readline.Completer = readline.FilenameCompleter readline.Completer = readline.FilenameCompleter
readline.LoadHistory(homedir + "/.hilbish-history") readline.LoadHistory(homedir + "/.hilbish-history")
for { RunInput(*cmdflag)
for interactive {
running = false running = false
input, err := readline.String(fmtPrompt()) input, err := readline.String(fmtPrompt())
if err == io.EOF { if err == io.EOF {
// Exit if user presses ^D (ctrl + d) // Exit if user presses ^D (ctrl + d)
fmt.Println("") fmt.Println("")
@ -114,9 +136,7 @@ func main() {
} }
input = strings.TrimSpace(input) input = strings.TrimSpace(input)
if len(input) == 0 { if len(input) == 0 { continue }
continue
}
if strings.HasSuffix(input, "\\") { if strings.HasSuffix(input, "\\") {
for { for {
@ -134,7 +154,7 @@ func main() {
if err != nil { if err != nil {
continue 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) 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) // This semi cursed function formats our prompt (obviously)

View File

@ -8,8 +8,8 @@ import (
"os" "os"
"strings" "strings"
"github.com/bobappleyard/readline"
"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"
@ -31,7 +31,9 @@ func RunInput(input string) {
// If alias was found, use command alias // If alias was found, use command alias
if aliases[cmdArgs[0]] != "" { 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 // 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 { func StartMultiline(prev string, sb *strings.Builder) bool {
// sb fromt outside is passed so we can // sb fromt outside is passed so we can
// save input from previous prompts // save input from previous prompts
if sb.String() == "" { if sb.String() == "" { sb.WriteString(prev + " ") }
sb.WriteString(prev + "\n")
}
fmt.Print(multilinePrompt) fmt.Print(multilinePrompt)
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
cont, err := reader.ReadString('\n') cont, err := reader.ReadString('\n')
cont = strings.TrimSuffix(cont, "\n") + " "
if err == io.EOF { if err == io.EOF {
// Exit when ^D // Exit when ^D
fmt.Println("") fmt.Println("")