mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "2cf979401bd28307746278a491f656118e976c81" and "72194898bac87c725c10ad7a8d10d02830af5297" have entirely different histories.
2cf979401b
...
72194898ba
37
CHANGELOG.md
37
CHANGELOG.md
|
@ -2,42 +2,6 @@
|
||||||
|
|
||||||
This is the changelog for the Hilbish shell made in Go and Lua.
|
This is the changelog for the Hilbish shell made in Go and Lua.
|
||||||
|
|
||||||
## [0.6.0] - 2021-10-17
|
|
||||||
## Added
|
|
||||||
- Hilbish will expand `~` in the preloadPath and samplePathConf variables. These are for compile time.
|
|
||||||
- On Windows, the hostname in `%u` has been removed.
|
|
||||||
- Made it easier to compile on Windows by adding Windows-tailored vars and paths.
|
|
||||||
- Add require paths `./libs/?/?.lua`
|
|
||||||
- Hilbish will now respect $XDG_CONFIG_HOME and will load its config and history there first and use Lua libraries in there and $XDG_DATA_HOME if they are set. (#71)
|
|
||||||
- If not, Hilbish will still default to `~`
|
|
||||||
- Added some new hooks
|
|
||||||
- `command.precmd` is thrown right before Hilbish prompts for input
|
|
||||||
- `command.preexec` is thrown right before Hilbish executes a command. It passes 2 arguments: the command as the user typed, and what Hilbish will actually execute (resolved alias)
|
|
||||||
- `hilbish.dataDir` is now available to know the directory of Hilbish data files (default config, docs, preload, etc)
|
|
||||||
- A `docgen` program has been added to `cmd/docgen` in the GitHub repository, As the name suggests, it will output docs in a `docs` folder for functions implemented in Go
|
|
||||||
- All hilbish modules/libraries now have a `__doc` metatable entry which is simply a short description of the module.
|
|
||||||
- `fs.readdir(dir)` has been added. It will return a table of files in `dir`
|
|
||||||
- Errors in the `fs.mkdir` function are now handled.
|
|
||||||
- **Breaking Change:** `fs.cd` no longer returns a numeric code to indicate error. Instead, it returns an error message.
|
|
||||||
- The `doc` command has been added to document functions of Hilbish libraries. Run the command for more details.
|
|
||||||
- `link(url, text)` has been added to `ansikit`. It returns a string which can be printed to produce a hyperlink in a terminal. Note that not all terminals support this feature.
|
|
||||||
- The [Succulent](https://github.com/Rosettea/Succulent) library has been added. This includes more utility functions and expansions to the Lua standard library itself.
|
|
||||||
- The command string is now passed to the `command.exit` hook
|
|
||||||
|
|
||||||
# Changed
|
|
||||||
- Hilbish won't print an extra newline at exit with ctrl + d
|
|
||||||
- `command.exit` with 0 exit code will now be thrown if input is nothing
|
|
||||||
- **Breaking Change:** `fs.stat` has been made better. It returns a proper table instead of userdata, and has fields instead of functions
|
|
||||||
- It includes `name`, `mode` as a octal representation in a string, `isDir`, and `size`
|
|
||||||
|
|
||||||
# Fixed
|
|
||||||
- `timeout()` is now blocking
|
|
||||||
- Directories with spaces in them can now be `cd`'d to
|
|
||||||
- An alias with the same name as the command will now not cause a freeze (#73)
|
|
||||||
- Userdata is no longer returned in the following cases:
|
|
||||||
- Commander arguments
|
|
||||||
- `fs` functions
|
|
||||||
|
|
||||||
## [0.5.1] - 2021-06-16
|
## [0.5.1] - 2021-06-16
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
@ -239,7 +203,6 @@ This input for example will prompt for more input to complete:
|
||||||
|
|
||||||
First "stable" release of Hilbish.
|
First "stable" release of Hilbish.
|
||||||
|
|
||||||
[0.6.0]: https://github.com/Rosettea/Hilbish/compare/v0.5.1...v0.6.0
|
|
||||||
[0.5.1]: https://github.com/Rosettea/Hilbish/compare/v0.5.0...v0.5.1
|
[0.5.1]: https://github.com/Rosettea/Hilbish/compare/v0.5.0...v0.5.1
|
||||||
[0.5.0]: https://github.com/Rosettea/Hilbish/compare/v0.4.0...v0.5.0
|
[0.5.0]: https://github.com/Rosettea/Hilbish/compare/v0.4.0...v0.5.0
|
||||||
[0.4.0]: https://github.com/Rosettea/Hilbish/compare/v0.3.2...v0.4.0
|
[0.4.0]: https://github.com/Rosettea/Hilbish/compare/v0.3.2...v0.4.0
|
||||||
|
|
10
README.md
10
README.md
|
@ -26,6 +26,11 @@ to make your life in a terminal easier.
|
||||||
<img src="gallery/pillprompt.png">
|
<img src="gallery/pillprompt.png">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
# Links
|
||||||
|
- **[Documentation](https://github.com/Hilbis/Hilbish/wiki)**
|
||||||
|
- **[Gallery](https://github.com/Hilbis/Hilbish/discussions/36)** - See
|
||||||
|
more screenshots of Hilbish in action
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
**NOTE:** Hilbish is currently only officially supported and tested on Linux
|
**NOTE:** Hilbish is currently only officially supported and tested on Linux
|
||||||
|
|
||||||
|
@ -53,11 +58,6 @@ Or from the latest `master` commit with:
|
||||||
yay -S hilbish-git
|
yay -S hilbish-git
|
||||||
```
|
```
|
||||||
|
|
||||||
### Nixpkgs
|
|
||||||
Nix/NixOS users can install Hilbish from the central repository, nixpkgs, through the usual ways.
|
|
||||||
|
|
||||||
If you're new to nix you should probably read up on how to do that [here](https://nixos.wiki/wiki/Cheatsheet).
|
|
||||||
|
|
||||||
### Manual Build
|
### Manual Build
|
||||||
#### Prerequisites
|
#### Prerequisites
|
||||||
- [Go 1.16+](https://go.dev)
|
- [Go 1.16+](https://go.dev)
|
||||||
|
|
|
@ -39,7 +39,7 @@ func HilbishLoader(L *lua.LState) int {
|
||||||
|
|
||||||
xdg := L.NewTable()
|
xdg := L.NewTable()
|
||||||
L.SetField(xdg, "config", lua.LString(confDir))
|
L.SetField(xdg, "config", lua.LString(confDir))
|
||||||
L.SetField(xdg, "data", lua.LString(getenv("XDG_DATA_HOME", homedir + "/.local/share")))
|
L.SetField(xdg, "data", lua.LString(getenv("XDG_DATA_HOME", homedir + "/.local/share/")))
|
||||||
L.SetField(mod, "xdg", xdg)
|
L.SetField(mod, "xdg", xdg)
|
||||||
|
|
||||||
util.Document(L, mod, "A miscellaneous sort of \"core\" API for things that relate to the shell itself and others.")
|
util.Document(L, mod, "A miscellaneous sort of \"core\" API for things that relate to the shell itself and others.")
|
||||||
|
|
|
@ -80,7 +80,7 @@ end
|
||||||
ansikit.link = function(url, text)
|
ansikit.link = function(url, text)
|
||||||
if not url then error 'ansikit: missing url for hyperlink' end
|
if not url then error 'ansikit: missing url for hyperlink' end
|
||||||
local text = (text and text or 'link')
|
local text = (text and text or 'link')
|
||||||
return lunacolors.blue('\27]8;;' .. url .. '\27\\' .. text .. '\27]8;;\27\\\n')
|
io.write(lunacolors.blue('\27]8;;' .. url .. '\27\\' .. text .. '\27]8;;\27\\\n'))
|
||||||
end
|
end
|
||||||
|
|
||||||
ansikit.print = function(text)
|
ansikit.print = function(text)
|
||||||
|
|
36
shell.go
36
shell.go
|
@ -10,6 +10,7 @@ import (
|
||||||
// "github.com/bobappleyard/readline"
|
// "github.com/bobappleyard/readline"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
// "github.com/yuin/gopher-lua/parse"
|
// "github.com/yuin/gopher-lua/parse"
|
||||||
|
"layeh.com/gopher-luar"
|
||||||
"mvdan.cc/sh/v3/interp"
|
"mvdan.cc/sh/v3/interp"
|
||||||
"mvdan.cc/sh/v3/syntax"
|
"mvdan.cc/sh/v3/syntax"
|
||||||
)
|
)
|
||||||
|
@ -50,7 +51,7 @@ func RunInput(input string) {
|
||||||
err = l.PCall(0, lua.MultRet, nil)
|
err = l.PCall(0, lua.MultRet, nil)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cmdFinish(0, cmdString)
|
hooks.Em.Emit("command.exit", 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if commands[cmdArgs[0]] != nil {
|
if commands[cmdArgs[0]] != nil {
|
||||||
|
@ -67,7 +68,7 @@ func RunInput(input string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprintln(os.Stderr,
|
||||||
"Error in command:\n\n" + err.Error())
|
"Error in command:\n\n" + err.Error())
|
||||||
cmdFinish(1, cmdString)
|
hooks.Em.Emit("command.exit", 1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
luaexitcode := l.Get(-1)
|
luaexitcode := l.Get(-1)
|
||||||
|
@ -79,7 +80,7 @@ func RunInput(input string) {
|
||||||
exitcode = uint8(code)
|
exitcode = uint8(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdFinish(exitcode, cmdString)
|
hooks.Em.Emit("command.exit", exitcode)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,22 +98,22 @@ func RunInput(input string) {
|
||||||
if syntax.IsIncomplete(err) || strings.HasSuffix(input, "\\") {
|
if syntax.IsIncomplete(err) || strings.HasSuffix(input, "\\") {
|
||||||
continue
|
continue
|
||||||
} else if code, ok := interp.IsExitStatus(err); ok {
|
} else if code, ok := interp.IsExitStatus(err); ok {
|
||||||
cmdFinish(code, cmdString)
|
hooks.Em.Emit("command.exit", code)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
cmdFinish(1, cmdString)
|
hooks.Em.Emit("command.exit", 1)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if code, ok := interp.IsExitStatus(err); ok {
|
if code, ok := interp.IsExitStatus(err); ok {
|
||||||
cmdFinish(code, cmdString)
|
hooks.Em.Emit("command.exit", code)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmdFinish(0, cmdString)
|
hooks.Em.Emit("command.exit", 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,32 +129,20 @@ func execCommand(cmd string) error {
|
||||||
_, argstring := splitInput(strings.Join(args, " "))
|
_, argstring := splitInput(strings.Join(args, " "))
|
||||||
|
|
||||||
// If alias was found, use command alias
|
// If alias was found, use command alias
|
||||||
for aliases[args[0]] != "" {
|
if aliases[args[0]] != "" {
|
||||||
alias := aliases[args[0]]
|
alias := aliases[args[0]]
|
||||||
argstring = alias + strings.TrimPrefix(argstring, args[0])
|
argstring = alias + strings.TrimPrefix(argstring, args[0])
|
||||||
cmdArgs, _ := splitInput(argstring)
|
cmdArgs, _ := splitInput(argstring)
|
||||||
args = cmdArgs
|
args = cmdArgs
|
||||||
|
|
||||||
if aliases[args[0]] == alias {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if aliases[args[0]] != "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If command is defined in Lua then run it
|
// If command is defined in Lua then run it
|
||||||
luacmdArgs := l.NewTable()
|
|
||||||
for _, str := range args[1:] {
|
|
||||||
luacmdArgs.Append(lua.LString(str))
|
|
||||||
}
|
|
||||||
|
|
||||||
if commands[args[0]] != nil {
|
if commands[args[0]] != nil {
|
||||||
err := l.CallByParam(lua.P{
|
err := l.CallByParam(lua.P{
|
||||||
Fn: commands[args[0]],
|
Fn: commands[args[0]],
|
||||||
NRet: 1,
|
NRet: 1,
|
||||||
Protect: true,
|
Protect: true,
|
||||||
}, luacmdArgs)
|
}, luar.New(l, args[1:]))
|
||||||
luaexitcode := l.Get(-1)
|
luaexitcode := l.Get(-1)
|
||||||
var exitcode uint8 = 0
|
var exitcode uint8 = 0
|
||||||
|
|
||||||
|
@ -167,7 +156,7 @@ func execCommand(cmd string) error {
|
||||||
fmt.Fprintln(os.Stderr,
|
fmt.Fprintln(os.Stderr,
|
||||||
"Error in command:\n\n" + err.Error())
|
"Error in command:\n\n" + err.Error())
|
||||||
}
|
}
|
||||||
cmdFinish(exitcode, argstring)
|
hooks.Em.Emit("command.exit", exitcode)
|
||||||
return interp.NewExitStatus(exitcode)
|
return interp.NewExitStatus(exitcode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,6 +229,3 @@ func splitInput(input string) ([]string, string) {
|
||||||
return cmdArgs, cmdstr.String()
|
return cmdArgs, cmdstr.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdFinish(code uint8, cmdstr string) {
|
|
||||||
hooks.Em.Emit("command.exit", code, cmdstr)
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,15 +4,15 @@ package main
|
||||||
|
|
||||||
// String vars that are free to be changed at compile time
|
// String vars that are free to be changed at compile time
|
||||||
var (
|
var (
|
||||||
requirePaths = commonRequirePaths + `.. ';'
|
requirePaths = commonRequirePaths + `
|
||||||
.. hilbish.dataDir .. '/libs/?/init.lua;'
|
.. ';/usr/share/hilbish/libs/?/init.lua;'
|
||||||
.. hilbish.dataDir .. '/libs/?/?.lua;'` + linuxUserPaths
|
.. ';/usr/share/hilbish/libs/?/?.lua;'` + linuxUserPaths
|
||||||
linuxUserPaths = `
|
linuxUserPaths = `
|
||||||
.. hilbish.xdg.data .. '/hilbish/libs/?/init.lua;'
|
.. hilbish.xdg.data .. '/hilbish/libs/?/init.lua;'
|
||||||
.. hilbish.xdg.data .. '/hilbish/libs/?/?.lua;'
|
.. hilbish.xdg.data .. '/hilbish/libs/?/?.lua;'
|
||||||
.. hilbish.xdg.data .. '/hilbish/libs/?.lua;'
|
.. hilbish.xdg.data .. '/hilbish/libs/?.lua'
|
||||||
.. hilbish.xdg.config .. '/hilbish/?/init.lua;'
|
.. hilbish.xdg.config .. '/hilbish/?/init.lua'
|
||||||
.. hilbish.xdg.config .. '/hilbish/?/?.lua;'
|
.. hilbish.xdg.config .. '/hilbish/?/?.lua'
|
||||||
.. hilbish.xdg.config .. '/hilbish/?.lua'`
|
.. hilbish.xdg.config .. '/hilbish/?.lua'`
|
||||||
dataDir = "/usr/share/hilbish"
|
dataDir = "/usr/share/hilbish"
|
||||||
preloadPath = dataDir + "/preload.lua"
|
preloadPath = dataDir + "/preload.lua"
|
||||||
|
|
Loading…
Reference in New Issue