mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "6eea5bce47646f27eaed44aa147f53429c0a1fd7" and "587d08773f7c11e71b66fad1b8cb78adcf5cd33e" have entirely different histories.
6eea5bce47
...
587d08773f
|
@ -26,10 +26,8 @@ jobs:
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '1.17.7'
|
go-version: '1.17.7'
|
||||||
- name: Download Task
|
|
||||||
run: 'sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d'
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} ./bin/task
|
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} make
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
if: matrix.goos == 'windows'
|
if: matrix.goos == 'windows'
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -9,6 +9,8 @@ local function doPrompt(fail)
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print(lunacolors.format(hilbish.greeting))
|
||||||
|
|
||||||
doPrompt()
|
doPrompt()
|
||||||
|
|
||||||
bait.catch('command.exit', function(code)
|
bait.catch('command.exit', function(code)
|
||||||
|
|
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -1,10 +1,6 @@
|
||||||
# 🎀 Changelog
|
# 🎀 Changelog
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
**NOTE:** Hilbish now uses [Task] insead of Make for builds.
|
|
||||||
|
|
||||||
[Task]: https://taskfile.dev/#/
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Inline hints, akin to fish and the others.
|
- Inline hints, akin to fish and the others.
|
||||||
To make a handler for hint text, you can set the `hilbish.hinter` function.
|
To make a handler for hint text, you can set the `hilbish.hinter` function.
|
||||||
|
@ -61,10 +57,6 @@ having and using multiple runners.
|
||||||
- `fs.pathListSep` is the separator for $PATH env entries
|
- `fs.pathListSep` is the separator for $PATH env entries
|
||||||
- Lua modules located in `hilbish.userDir.data .. '/hilbish/start'` (like `~/.local/share/hilbish/start/foo/init.lua`)
|
- Lua modules located in `hilbish.userDir.data .. '/hilbish/start'` (like `~/.local/share/hilbish/start/foo/init.lua`)
|
||||||
will be ran on startup
|
will be ran on startup
|
||||||
- `hilbish.init` hook, thrown after Hilbish has initialized Lua side
|
|
||||||
- Message of the day on startup (`hilbish.motd`), mainly intended as quick
|
|
||||||
small news pieces for releases. It is printed by default. To disable it,
|
|
||||||
set `hilbish.opts.motd` to false.
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- **Breaking Change:** Upgraded to Lua 5.4.
|
- **Breaking Change:** Upgraded to Lua 5.4.
|
||||||
|
@ -81,12 +73,11 @@ User input has been added to the return to account for runners wanting to
|
||||||
prompt for continued input, and to add it properly to history. `continue`
|
prompt for continued input, and to add it properly to history. `continue`
|
||||||
got added so that it would be easier for runners to get continued input
|
got added so that it would be easier for runners to get continued input
|
||||||
without having to actually handle it at all.
|
without having to actually handle it at all.
|
||||||
|
|
||||||
- **Breaking Change:** Job objects and timers are now Lua userdata instead
|
- **Breaking Change:** Job objects and timers are now Lua userdata instead
|
||||||
of a table, so their functions require you to call them with a colon instead
|
of a table, so their functions require you to call them with a colon instead
|
||||||
of a dot. (ie. `job.stop()` -> `job:stop()`)
|
of a dot. (ie. `job.stop()` -> `job:stop()`)
|
||||||
- All `fs` module functions which take paths now implicitly expand ~ to home.
|
- All `fs` module functions which take paths now implicitly expand ~ to home.
|
||||||
- **Breaking Change:** `hilbish.greeting` has been moved to an opt (`hilbish.opts.greeting`) and is
|
|
||||||
always printed by default. To disable it, set the opt to false.
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- If in Vim replace mode, input at the end of the line inserts instead of
|
- If in Vim replace mode, input at the end of the line inserts instead of
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
PREFIX ?= /usr
|
||||||
|
BINDIR ?= $(PREFIX)/bin
|
||||||
|
LIBDIR ?= $(PREFIX)/share/hilbish
|
||||||
|
|
||||||
|
MY_GOFLAGS = -ldflags "-s -w"
|
||||||
|
|
||||||
|
all: dev
|
||||||
|
|
||||||
|
dev: MY_GOFLAGS = -ldflags "-s -w -X main.gitCommit=$(shell git rev-parse --short HEAD) -X main.gitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
|
||||||
|
dev: build
|
||||||
|
|
||||||
|
build:
|
||||||
|
go build $(MY_GOFLAGS)
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish"
|
||||||
|
mkdir -p "$(DESTDIR)$(LIBDIR)"
|
||||||
|
cp -r libs docs emmyLuaDocs nature .hilbishrc.lua "$(DESTDIR)$(LIBDIR)"
|
||||||
|
grep -qxF "$(DESTDIR)$(BINDIR)/hilbish" /etc/shells || echo "$(DESTDIR)$(BINDIR)/hilbish" >> /etc/shells
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -vrf \
|
||||||
|
"$(DESTDIR)$(BINDIR)/hilbish" \
|
||||||
|
"$(DESTDIR)$(LIBDIR)"
|
||||||
|
sed -i '/hilbish/d' /etc/shells
|
||||||
|
|
||||||
|
clean:
|
||||||
|
go clean
|
||||||
|
|
||||||
|
.PHONY: all dev build install uninstall clean
|
|
@ -1,36 +0,0 @@
|
||||||
# https://taskfile.dev
|
|
||||||
|
|
||||||
version: '3'
|
|
||||||
|
|
||||||
vars:
|
|
||||||
PREFIX: '{{default "/usr" .PREFIX}}'
|
|
||||||
bindir__: '{{.PREFIX}}/bin'
|
|
||||||
BINDIR: '{{default .bindir__ .BINDIR}}'
|
|
||||||
libdir__: '{{.PREFIX}}/share/hilbish'
|
|
||||||
LIBDIR: '{{default .libdir__ .LIBDIR}}'
|
|
||||||
GOFLAGS: '-ldflags "-s -w"'
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
default:
|
|
||||||
cmds:
|
|
||||||
- go build {{.GOFLAGS}}
|
|
||||||
vars:
|
|
||||||
GOFLAGS: '-ldflags "-s -w -X main.gitCommit=$(git rev-parse --short HEAD) -X main.gitBranch=$(git rev-parse --abbrev-ref HEAD)"'
|
|
||||||
|
|
||||||
build:
|
|
||||||
cmds:
|
|
||||||
- go build {{.GOFLAGS}}
|
|
||||||
|
|
||||||
install:
|
|
||||||
cmds:
|
|
||||||
- install -v -d "{{.DESTDIR}}{{.BINDIR}}/" && install -m 0755 -v hilbish "{{.DESTDIR}}{{.BINDIR}}/hilbish"
|
|
||||||
- mkdir -p "{{.DESTDIR}}{{.LIBDIR}}"
|
|
||||||
- cp -r libs docs emmyLuaDocs nature .hilbishrc.lua {{.DESTDIR}}{{.LIBDIR}}
|
|
||||||
- grep -qxF "{{.DESTDIR}}{{.BINDIR}}/hilbish" /etc/shells || echo "{{.DESTDIR}}{{.BINDIR}}/hilbish" >> /etc/shells
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
cmds:
|
|
||||||
- rm -vrf
|
|
||||||
"{{.DESTDIR}}{{.BINDIR}}/hilbish"
|
|
||||||
"{{.DESTDIR}}{{.LIBDIR}}"
|
|
||||||
- sed -i '/hilbish/d' /etc/shells
|
|
6
api.go
6
api.go
|
@ -44,6 +44,7 @@ var exports = map[string]util.LuaExport{
|
||||||
"which": {hlwhich, 1, false},
|
"which": {hlwhich, 1, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var greeting string
|
||||||
var hshMod *rt.Table
|
var hshMod *rt.Table
|
||||||
var hilbishLoader = packagelib.Loader{
|
var hilbishLoader = packagelib.Loader{
|
||||||
Load: hilbishLoad,
|
Load: hilbishLoad,
|
||||||
|
@ -102,6 +103,10 @@ func hilbishLoad(rtm *rt.Runtime) (rt.Value, func()) {
|
||||||
username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows
|
username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
greeting = `Welcome to {magenta}Hilbish{reset}, {cyan}` + username + `{reset}.
|
||||||
|
The nice lil shell for {blue}Lua{reset} fanatics!
|
||||||
|
Check out the {blue}{bold}guide{reset} command to get started.
|
||||||
|
`
|
||||||
util.SetFieldProtected(fakeMod, mod, "ver", rt.StringValue(getVersion()), "Hilbish version")
|
util.SetFieldProtected(fakeMod, mod, "ver", rt.StringValue(getVersion()), "Hilbish version")
|
||||||
util.SetFieldProtected(fakeMod, mod, "user", rt.StringValue(username), "Username of user")
|
util.SetFieldProtected(fakeMod, mod, "user", rt.StringValue(username), "Username of user")
|
||||||
util.SetFieldProtected(fakeMod, mod, "host", rt.StringValue(host), "Host name of the machine")
|
util.SetFieldProtected(fakeMod, mod, "host", rt.StringValue(host), "Host name of the machine")
|
||||||
|
@ -109,6 +114,7 @@ func hilbishLoad(rtm *rt.Runtime) (rt.Value, func()) {
|
||||||
util.SetFieldProtected(fakeMod, mod, "dataDir", rt.StringValue(dataDir), "Directory for Hilbish's data files")
|
util.SetFieldProtected(fakeMod, mod, "dataDir", rt.StringValue(dataDir), "Directory for Hilbish's data files")
|
||||||
util.SetFieldProtected(fakeMod, mod, "interactive", rt.BoolValue(interactive), "If this is an interactive shell")
|
util.SetFieldProtected(fakeMod, mod, "interactive", rt.BoolValue(interactive), "If this is an interactive shell")
|
||||||
util.SetFieldProtected(fakeMod, mod, "login", rt.BoolValue(login), "Whether this is a login shell")
|
util.SetFieldProtected(fakeMod, mod, "login", rt.BoolValue(login), "Whether this is a login shell")
|
||||||
|
util.SetFieldProtected(fakeMod, mod, "greeting", rt.StringValue(greeting), "Hilbish's welcome message for interactive shells. It has Lunacolors formatting.")
|
||||||
util.SetFieldProtected(fakeMod, mod, "vimMode", rt.NilValue, "Current Vim mode of Hilbish (nil if not in Vim mode)")
|
util.SetFieldProtected(fakeMod, mod, "vimMode", rt.NilValue, "Current Vim mode of Hilbish (nil if not in Vim mode)")
|
||||||
util.SetFieldProtected(fakeMod, mod, "exitCode", rt.IntValue(0), "Exit code of last exected command")
|
util.SetFieldProtected(fakeMod, mod, "exitCode", rt.IntValue(0), "Exit code of last exected command")
|
||||||
util.Document(fakeMod, "Hilbish's core API, containing submodules and functions which relate to the shell itself.")
|
util.Document(fakeMod, "Hilbish's core API, containing submodules and functions which relate to the shell itself.")
|
||||||
|
|
32
complete.go
32
complete.go
|
@ -11,34 +11,8 @@ import (
|
||||||
rt "github.com/arnodel/golua/runtime"
|
rt "github.com/arnodel/golua/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func splitQuote(str string) []string {
|
|
||||||
split := []string{}
|
|
||||||
sb := &strings.Builder{}
|
|
||||||
quoted := false
|
|
||||||
|
|
||||||
for _, r := range str {
|
|
||||||
if r == '"' {
|
|
||||||
quoted = !quoted
|
|
||||||
sb.WriteRune(r)
|
|
||||||
} else if !quoted && r == ' ' {
|
|
||||||
split = append(split, sb.String())
|
|
||||||
sb.Reset()
|
|
||||||
} else {
|
|
||||||
sb.WriteRune(r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if sb.Len() > 0 {
|
|
||||||
split = append(split, sb.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
return split
|
|
||||||
}
|
|
||||||
|
|
||||||
func fileComplete(query, ctx string, fields []string) ([]string, string) {
|
func fileComplete(query, ctx string, fields []string) ([]string, string) {
|
||||||
q := splitQuote(ctx)
|
return matchPath(query)
|
||||||
|
|
||||||
return matchPath(q[len(q) - 1])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func binaryComplete(query, ctx string, fields []string) ([]string, string) {
|
func binaryComplete(query, ctx string, fields []string) ([]string, string) {
|
||||||
|
@ -94,8 +68,6 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchPath(query string) ([]string, string) {
|
func matchPath(query string) ([]string, string) {
|
||||||
oldQuery := query
|
|
||||||
query = strings.TrimPrefix(query, "\"")
|
|
||||||
var entries []string
|
var entries []string
|
||||||
var baseName string
|
var baseName string
|
||||||
|
|
||||||
|
@ -115,9 +87,7 @@ func matchPath(query string) ([]string, string) {
|
||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
entry = entry + string(os.PathSeparator)
|
entry = entry + string(os.PathSeparator)
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(oldQuery, "\"") {
|
|
||||||
entry = escapeFilename(entry)
|
entry = escapeFilename(entry)
|
||||||
}
|
|
||||||
entries = append(entries, entry)
|
entries = append(entries, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
main.go
1
main.go
|
@ -138,7 +138,6 @@ func main() {
|
||||||
} else {
|
} else {
|
||||||
runConfig(*configflag)
|
runConfig(*configflag)
|
||||||
}
|
}
|
||||||
hooks.Em.Emit("hilbish.init")
|
|
||||||
|
|
||||||
if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
|
if fileInfo, _ := os.Stdin.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
|
||||||
scanner := bufio.NewScanner(bufio.NewReader(os.Stdin))
|
scanner := bufio.NewScanner(bufio.NewReader(os.Stdin))
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
local bait = require 'bait'
|
|
||||||
local lunacolors = require 'lunacolors'
|
|
||||||
|
|
||||||
bait.catch('hilbish.init', function()
|
|
||||||
if hilbish.interactive and type(hilbish.opts.greeting) == 'string' then
|
|
||||||
print(lunacolors.format(hilbish.opts.greeting))
|
|
||||||
end
|
|
||||||
end)
|
|
|
@ -20,11 +20,7 @@ local function setupOpt(name, default)
|
||||||
end
|
end
|
||||||
|
|
||||||
local defaultOpts = {
|
local defaultOpts = {
|
||||||
autocd = false,
|
autocd = false
|
||||||
greeting = string.format([[Welcome to {magenta}Hilbish{reset}, {cyan}%s{reset}.
|
|
||||||
The nice lil shell for {blue}Lua{reset} fanatics!
|
|
||||||
]], hilbish.user),
|
|
||||||
motd = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for optsName, default in pairs(defaultOpts) do
|
for optsName, default in pairs(defaultOpts) do
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
local bait = require 'bait'
|
|
||||||
local lunacolors = require 'lunacolors'
|
|
||||||
|
|
||||||
hilbish.motd = [[
|
|
||||||
Hilbish 2.0 is a {red}major{reset} update! If your config doesn't work
|
|
||||||
anymore, that will definitely be why! A MOTD, very message, much day.
|
|
||||||
]]
|
|
||||||
|
|
||||||
bait.catch('hilbish.init', function()
|
|
||||||
if hilbish.opts.motd then
|
|
||||||
print(lunacolors.format(hilbish.motd))
|
|
||||||
end
|
|
||||||
end)
|
|
Loading…
Reference in New Issue