mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "21b093559a6c911733b26b7e5cb81830475542d3" and "fd513b6ae307ebd9596fea1176c87ba474234c17" have entirely different histories.
21b093559a
...
fd513b6ae3
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -22,22 +22,19 @@ with Lua
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- The minimal config is truly minimal now
|
- The minimal config is truly minimal now
|
||||||
#### Breaking Changes
|
- (Possibly) **Breaking Change:** Change default SHLVL to 0 instead of 1
|
||||||
(there were a lot...)
|
- **Breaking Change:** ~/.hilbishrc.lua will no longer be run by default, it now
|
||||||
- Change default SHLVL to 0 instead of 1
|
|
||||||
- ~/.hilbishrc.lua will no longer be run by default, it now
|
|
||||||
only uses the paths mentioned below.
|
only uses the paths mentioned below.
|
||||||
- Changed Hilbish's config path to something more suited
|
- **Breaking Change:** Changed Hilbish's config path to something more suited
|
||||||
according to the OS (`$XDG_CONFIG_HOME/hilbish/init.lua` on Linux,
|
according to the OS (`$XDG_CONFIG_HOME/hilbish/init.lua` on Linux,
|
||||||
`~/Library/Application Support/hilbish/init.lua` on MacOs and
|
`~/Library/Application Support/hilbish/init.lua` on MacOs and
|
||||||
(`%APPDATA%/hilbish/init.lua` on Windows). Previously on Unix-like it was
|
(`%APPDATA%/hilbish/init.lua` on Windows). Previously on Unix-like it was
|
||||||
`$XDG_CONFIG_HOME/hilbish/hilbishrc.lua`
|
`$XDG_CONFIG_HOME/hilbish/hilbishrc.lua`
|
||||||
- The history path has been changed to a better suited path.
|
- **Breaking Change:** The history path has been changed to a better suited path.
|
||||||
On Linux, it is `$XDG_DATA_HOME/hilbish/.hilbish-history` and for others it is
|
On Linux, it is `$XDG_DATA_HOME/hilbish/.hilbish-history` and for others it is
|
||||||
the config path.
|
the config path.
|
||||||
- `hilbish.xdg` no longer exists, use `hilbish.userDir` instead,
|
- **Breaking Change:** `hilbish.xdg` no longer exists, use `hilbish.userDir` instead,
|
||||||
as it functions the same and is OS agnostic
|
as it functions the same and is OS agnostic
|
||||||
- `hilbish.flag` has been removed
|
|
||||||
|
|
||||||
## [0.7.1] - 2021-11-22
|
## [0.7.1] - 2021-11-22
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
38
api.go
38
api.go
|
@ -14,6 +14,7 @@ import (
|
||||||
|
|
||||||
"hilbish/util"
|
"hilbish/util"
|
||||||
|
|
||||||
|
"github.com/pborman/getopt"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"mvdan.cc/sh/v3/interp"
|
"mvdan.cc/sh/v3/interp"
|
||||||
)
|
)
|
||||||
|
@ -23,6 +24,7 @@ var exports = map[string]lua.LGFunction {
|
||||||
"appendPath": hlappendPath,
|
"appendPath": hlappendPath,
|
||||||
"cwd": hlcwd,
|
"cwd": hlcwd,
|
||||||
"exec": hlexec,
|
"exec": hlexec,
|
||||||
|
"flag": hlflag,
|
||||||
"multiprompt": hlmlprompt,
|
"multiprompt": hlmlprompt,
|
||||||
"prependPath": hlprependPath,
|
"prependPath": hlprependPath,
|
||||||
"prompt": hlprompt,
|
"prompt": hlprompt,
|
||||||
|
@ -84,7 +86,6 @@ The nice lil shell for {blue}Lua{reset} fanatics!
|
||||||
|
|
||||||
// run(cmd)
|
// run(cmd)
|
||||||
// Runs `cmd` in Hilbish's sh interpreter.
|
// Runs `cmd` in Hilbish's sh interpreter.
|
||||||
// --- @param cmd string
|
|
||||||
func hlrun(L *lua.LState) int {
|
func hlrun(L *lua.LState) int {
|
||||||
var exitcode uint8
|
var exitcode uint8
|
||||||
cmd := L.CheckString(1)
|
cmd := L.CheckString(1)
|
||||||
|
@ -100,6 +101,23 @@ func hlrun(L *lua.LState) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flag(f)
|
||||||
|
// Checks if the `f` flag has been passed to Hilbish.
|
||||||
|
func hlflag(L *lua.LState) int {
|
||||||
|
flagchar := L.CheckString(1)
|
||||||
|
|
||||||
|
flag := getopt.Lookup([]rune(flagchar)[0])
|
||||||
|
if flag == nil {
|
||||||
|
L.Push(lua.LNil)
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
passed := flag.Seen()
|
||||||
|
L.Push(lua.LBool(passed))
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
// cwd()
|
// cwd()
|
||||||
// Returns the current directory of the shell
|
// Returns the current directory of the shell
|
||||||
func hlcwd(L *lua.LState) int {
|
func hlcwd(L *lua.LState) int {
|
||||||
|
@ -122,7 +140,6 @@ func getenv(key, fallback string) string {
|
||||||
// Read input from the user, using Hilbish's line editor/input reader.
|
// Read input from the user, using Hilbish's line editor/input reader.
|
||||||
// This is a separate instance from the one Hilbish actually uses.
|
// This is a separate instance from the one Hilbish actually uses.
|
||||||
// Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
// Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||||
// --- @param prompt string
|
|
||||||
func hlread(L *lua.LState) int {
|
func hlread(L *lua.LState) int {
|
||||||
luaprompt := L.CheckString(1)
|
luaprompt := L.CheckString(1)
|
||||||
lualr := newLineReader(luaprompt)
|
lualr := newLineReader(luaprompt)
|
||||||
|
@ -137,16 +154,13 @@ func hlread(L *lua.LState) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* prompt(str)
|
||||||
prompt(str)
|
|
||||||
Changes the shell prompt to `str`
|
Changes the shell prompt to `str`
|
||||||
There are a few verbs that can be used in the prompt text.
|
There are a few verbs that can be used in the prompt text.
|
||||||
These will be formatted and replaced with the appropriate values.
|
These will be formatted and replaced with the appropriate values.
|
||||||
`%d` - Current working directory
|
`%d` - Current working directory
|
||||||
`%u` - Name of current user
|
`%u` - Name of current user
|
||||||
`%h` - Hostname of device
|
`%h` - Hostname of device */
|
||||||
--- @param str string
|
|
||||||
*/
|
|
||||||
func hlprompt(L *lua.LState) int {
|
func hlprompt(L *lua.LState) int {
|
||||||
prompt = L.CheckString(1)
|
prompt = L.CheckString(1)
|
||||||
|
|
||||||
|
@ -155,7 +169,6 @@ func hlprompt(L *lua.LState) int {
|
||||||
|
|
||||||
// multiprompt(str)
|
// multiprompt(str)
|
||||||
// Changes the continued line prompt to `str`
|
// Changes the continued line prompt to `str`
|
||||||
// --- @param str string
|
|
||||||
func hlmlprompt(L *lua.LState) int {
|
func hlmlprompt(L *lua.LState) int {
|
||||||
multilinePrompt = L.CheckString(1)
|
multilinePrompt = L.CheckString(1)
|
||||||
|
|
||||||
|
@ -164,8 +177,6 @@ func hlmlprompt(L *lua.LState) int {
|
||||||
|
|
||||||
// alias(cmd, orig)
|
// alias(cmd, orig)
|
||||||
// Sets an alias of `orig` to `cmd`
|
// Sets an alias of `orig` to `cmd`
|
||||||
// --- @param cmd string
|
|
||||||
// --- @param orig string
|
|
||||||
func hlalias(L *lua.LState) int {
|
func hlalias(L *lua.LState) int {
|
||||||
alias := L.CheckString(1)
|
alias := L.CheckString(1)
|
||||||
source := L.CheckString(2)
|
source := L.CheckString(2)
|
||||||
|
@ -177,7 +188,6 @@ func hlalias(L *lua.LState) int {
|
||||||
|
|
||||||
// appendPath(dir)
|
// appendPath(dir)
|
||||||
// Appends `dir` to $PATH
|
// Appends `dir` to $PATH
|
||||||
// --- @param dir string|table
|
|
||||||
func hlappendPath(L *lua.LState) int {
|
func hlappendPath(L *lua.LState) int {
|
||||||
// check if dir is a table or a string
|
// check if dir is a table or a string
|
||||||
arg := L.Get(1)
|
arg := L.Get(1)
|
||||||
|
@ -207,7 +217,6 @@ func appendPath(dir string) {
|
||||||
|
|
||||||
// exec(cmd)
|
// exec(cmd)
|
||||||
// Replaces running hilbish with `cmd`
|
// Replaces running hilbish with `cmd`
|
||||||
// --- @param cmd string
|
|
||||||
func hlexec(L *lua.LState) int {
|
func hlexec(L *lua.LState) int {
|
||||||
cmd := L.CheckString(1)
|
cmd := L.CheckString(1)
|
||||||
cmdArgs, _ := splitInput(cmd)
|
cmdArgs, _ := splitInput(cmd)
|
||||||
|
@ -227,7 +236,6 @@ func hlexec(L *lua.LState) int {
|
||||||
|
|
||||||
// goro(fn)
|
// goro(fn)
|
||||||
// Puts `fn` in a goroutine
|
// Puts `fn` in a goroutine
|
||||||
// --- @param fn function
|
|
||||||
func hlgoroutine(L *lua.LState) int {
|
func hlgoroutine(L *lua.LState) int {
|
||||||
fn := L.CheckFunction(1)
|
fn := L.CheckFunction(1)
|
||||||
argnum := L.GetTop()
|
argnum := L.GetTop()
|
||||||
|
@ -250,8 +258,6 @@ func hlgoroutine(L *lua.LState) int {
|
||||||
|
|
||||||
// timeout(cb, time)
|
// timeout(cb, time)
|
||||||
// Runs the `cb` function after `time` in milliseconds
|
// Runs the `cb` function after `time` in milliseconds
|
||||||
// --- @param cb function
|
|
||||||
// --- @param time number
|
|
||||||
func hltimeout(L *lua.LState) int {
|
func hltimeout(L *lua.LState) int {
|
||||||
cb := L.CheckFunction(1)
|
cb := L.CheckFunction(1)
|
||||||
ms := L.CheckInt(2)
|
ms := L.CheckInt(2)
|
||||||
|
@ -269,8 +275,6 @@ func hltimeout(L *lua.LState) int {
|
||||||
|
|
||||||
// interval(cb, time)
|
// interval(cb, time)
|
||||||
// Runs the `cb` function every `time` milliseconds
|
// Runs the `cb` function every `time` milliseconds
|
||||||
// --- @param cb function
|
|
||||||
// --- @param time number
|
|
||||||
func hlinterval(L *lua.LState) int {
|
func hlinterval(L *lua.LState) int {
|
||||||
intervalfunc := L.CheckFunction(1)
|
intervalfunc := L.CheckFunction(1)
|
||||||
ms := L.CheckInt(2)
|
ms := L.CheckInt(2)
|
||||||
|
|
|
@ -12,6 +12,8 @@ cwd() > Returns the current directory of the shell
|
||||||
|
|
||||||
exec(cmd) > Replaces running hilbish with `cmd`
|
exec(cmd) > Replaces running hilbish with `cmd`
|
||||||
|
|
||||||
|
flag(f) > Checks if the `f` flag has been passed to Hilbish.
|
||||||
|
|
||||||
goro(fn) > Puts `fn` in a goroutine
|
goro(fn) > Puts `fn` in a goroutine
|
||||||
|
|
||||||
interval(cb, time) > Runs the `cb` function every `time` milliseconds
|
interval(cb, time) > Runs the `cb` function every `time` milliseconds
|
||||||
|
|
|
@ -3,13 +3,10 @@
|
||||||
local hilbish = {}
|
local hilbish = {}
|
||||||
|
|
||||||
--- Sets an alias of `orig` to `cmd`
|
--- Sets an alias of `orig` to `cmd`
|
||||||
--- @param cmd string
|
function hilbish.alias() end
|
||||||
--- @param orig string
|
|
||||||
function hilbish.alias(cmd, orig) end
|
|
||||||
|
|
||||||
--- Appends `dir` to $PATH
|
--- Appends `dir` to $PATH
|
||||||
--- @param dir string|table
|
function hilbish.appendPath() end
|
||||||
function hilbish.appendPath(dir) end
|
|
||||||
|
|
||||||
--- Registers a completion handler for `scope`.
|
--- Registers a completion handler for `scope`.
|
||||||
--- A `scope` is currently only expected to be `command.<cmd>`,
|
--- A `scope` is currently only expected to be `command.<cmd>`,
|
||||||
|
@ -22,21 +19,19 @@ function hilbish.complete() end
|
||||||
function hilbish.cwd() end
|
function hilbish.cwd() end
|
||||||
|
|
||||||
--- Replaces running hilbish with `cmd`
|
--- Replaces running hilbish with `cmd`
|
||||||
--- @param cmd string
|
function hilbish.exec() end
|
||||||
function hilbish.exec(cmd) end
|
|
||||||
|
--- Checks if the `f` flag has been passed to Hilbish.
|
||||||
|
function hilbish.flag() end
|
||||||
|
|
||||||
--- Puts `fn` in a goroutine
|
--- Puts `fn` in a goroutine
|
||||||
--- @param fn function
|
function hilbish.goroutine() end
|
||||||
function hilbish.goroutine(fn) end
|
|
||||||
|
|
||||||
--- Runs the `cb` function every `time` milliseconds
|
--- Runs the `cb` function every `time` milliseconds
|
||||||
--- @param cb function
|
function hilbish.interval() end
|
||||||
--- @param time number
|
|
||||||
function hilbish.interval(cb, time) end
|
|
||||||
|
|
||||||
--- Changes the continued line prompt to `str`
|
--- Changes the continued line prompt to `str`
|
||||||
--- @param str string
|
function hilbish.mlprompt() end
|
||||||
function hilbish.mlprompt(str) end
|
|
||||||
|
|
||||||
--- Prepends `dir` to $PATH
|
--- Prepends `dir` to $PATH
|
||||||
function hilbish.prependPath() end
|
function hilbish.prependPath() end
|
||||||
|
@ -47,22 +42,17 @@ function hilbish.prependPath() end
|
||||||
--- `%d` - Current working directory
|
--- `%d` - Current working directory
|
||||||
--- `%u` - Name of current user
|
--- `%u` - Name of current user
|
||||||
--- `%h` - Hostname of device
|
--- `%h` - Hostname of device
|
||||||
--- @param str string
|
function hilbish.prompt() end
|
||||||
function hilbish.prompt(str) end
|
|
||||||
|
|
||||||
--- Read input from the user, using Hilbish's line editor/input reader.
|
--- Read input from the user, using Hilbish's line editor/input reader.
|
||||||
--- This is a separate instance from the one Hilbish actually uses.
|
--- This is a separate instance from the one Hilbish actually uses.
|
||||||
--- Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
--- Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||||
--- @param prompt string
|
function hilbish.read() end
|
||||||
function hilbish.read(prompt) end
|
|
||||||
|
|
||||||
--- Runs `cmd` in Hilbish's sh interpreter.
|
--- Runs `cmd` in Hilbish's sh interpreter.
|
||||||
--- @param cmd string
|
function hilbish.run() end
|
||||||
function hilbish.run(cmd) end
|
|
||||||
|
|
||||||
--- Runs the `cb` function after `time` in milliseconds
|
--- Runs the `cb` function after `time` in milliseconds
|
||||||
--- @param cb function
|
function hilbish.timeout() end
|
||||||
--- @param time number
|
|
||||||
function hilbish.timeout(cb, time) end
|
|
||||||
|
|
||||||
return hilbish
|
return hilbish
|
||||||
|
|
6
go.mod
6
go.mod
|
@ -3,16 +3,12 @@ module hilbish
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Rosettea/Hilbiline v0.0.0-20210624011007-8088a2d84b65
|
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2
|
||||||
github.com/Rosettea/readline v0.0.0-20211207004608-4afb088da503
|
github.com/Rosettea/readline v0.0.0-20211207004608-4afb088da503
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
||||||
github.com/creack/goselect v0.1.2 // indirect
|
|
||||||
github.com/creack/termios v0.0.0-20160714173321-88d0029e36a1 // indirect
|
|
||||||
github.com/kr/pty v1.1.8 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||||
github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036
|
github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036
|
||||||
github.com/pborman/ansi v1.0.0 // indirect
|
|
||||||
github.com/pborman/getopt v1.1.0
|
github.com/pborman/getopt v1.1.0
|
||||||
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9
|
github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9
|
||||||
golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7 // indirect
|
golang.org/x/sys v0.0.0-20220224120231-95c6836cb0e7 // indirect
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -1,5 +1,3 @@
|
||||||
github.com/Rosettea/Hilbiline v0.0.0-20210624011007-8088a2d84b65 h1:z6alP313nLg1U/V3bKSd6849L/A2LxDSwKv4CPqqzDk=
|
|
||||||
github.com/Rosettea/Hilbiline v0.0.0-20210624011007-8088a2d84b65/go.mod h1:/FFZ4cgR6TXXYaskRUxyLIYdfG0PS4BPtWjWRQms754=
|
|
||||||
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2 h1:6f1umn6mkodpGf6rK9LZjr4Gut2uS+b8QLoFBFTeOE8=
|
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2 h1:6f1umn6mkodpGf6rK9LZjr4Gut2uS+b8QLoFBFTeOE8=
|
||||||
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2/go.mod h1:0J2+sRC+d4a3swcH20sVlFvYUEXASvGTHJnVTTI4S9w=
|
github.com/Rosettea/Hilbiline v0.0.0-20210710124707-aa6e3ff34cb2/go.mod h1:0J2+sRC+d4a3swcH20sVlFvYUEXASvGTHJnVTTI4S9w=
|
||||||
github.com/Rosettea/readline v0.0.0-20211207004608-4afb088da503 h1:hA2kXBwY8SFH3+PT67CkoUjlMuRN08RSEtsKjwQ+of4=
|
github.com/Rosettea/readline v0.0.0-20211207004608-4afb088da503 h1:hA2kXBwY8SFH3+PT67CkoUjlMuRN08RSEtsKjwQ+of4=
|
||||||
|
|
Loading…
Reference in New Issue