mirror of https://github.com/Hilbis/Hilbish
Compare commits
11 Commits
72194898ba
...
2cf979401b
Author | SHA1 | Date |
---|---|---|
sammyette | 2cf979401b | |
sammyette | 87fcdd3c10 | |
sammyette | 9f523ba3c0 | |
sammyette | e08e3b9b94 | |
sammyette | 00f41a95bc | |
sammyette | b1f4efd9ac | |
sammyette | 212a52fd04 | |
legendofmiracles | 0c7fadbaad | |
sammyette | a8ecd44efb | |
sammyette | ce4ba48da0 | |
sammyette | 7a4cbbddff |
37
CHANGELOG.md
37
CHANGELOG.md
|
@ -2,6 +2,42 @@
|
|||
|
||||
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
|
||||
|
||||
## Added
|
||||
|
@ -203,6 +239,7 @@ This input for example will prompt for more input to complete:
|
|||
|
||||
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.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
|
||||
|
|
10
README.md
10
README.md
|
@ -26,11 +26,6 @@ to make your life in a terminal easier.
|
|||
<img src="gallery/pillprompt.png">
|
||||
</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
|
||||
**NOTE:** Hilbish is currently only officially supported and tested on Linux
|
||||
|
||||
|
@ -58,6 +53,11 @@ Or from the latest `master` commit with:
|
|||
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
|
||||
#### Prerequisites
|
||||
- [Go 1.16+](https://go.dev)
|
||||
|
|
|
@ -39,7 +39,7 @@ func HilbishLoader(L *lua.LState) int {
|
|||
|
||||
xdg := L.NewTable()
|
||||
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)
|
||||
|
||||
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)
|
||||
if not url then error 'ansikit: missing url for hyperlink' end
|
||||
local text = (text and text or 'link')
|
||||
io.write(lunacolors.blue('\27]8;;' .. url .. '\27\\' .. text .. '\27]8;;\27\\\n'))
|
||||
return lunacolors.blue('\27]8;;' .. url .. '\27\\' .. text .. '\27]8;;\27\\\n')
|
||||
end
|
||||
|
||||
ansikit.print = function(text)
|
||||
|
|
36
shell.go
36
shell.go
|
@ -10,7 +10,6 @@ import (
|
|||
// "github.com/bobappleyard/readline"
|
||||
"github.com/yuin/gopher-lua"
|
||||
// "github.com/yuin/gopher-lua/parse"
|
||||
"layeh.com/gopher-luar"
|
||||
"mvdan.cc/sh/v3/interp"
|
||||
"mvdan.cc/sh/v3/syntax"
|
||||
)
|
||||
|
@ -51,7 +50,7 @@ func RunInput(input string) {
|
|||
err = l.PCall(0, lua.MultRet, nil)
|
||||
}
|
||||
if err == nil {
|
||||
hooks.Em.Emit("command.exit", 0)
|
||||
cmdFinish(0, cmdString)
|
||||
return
|
||||
}
|
||||
if commands[cmdArgs[0]] != nil {
|
||||
|
@ -68,7 +67,7 @@ func RunInput(input string) {
|
|||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr,
|
||||
"Error in command:\n\n" + err.Error())
|
||||
hooks.Em.Emit("command.exit", 1)
|
||||
cmdFinish(1, cmdString)
|
||||
return
|
||||
}
|
||||
luaexitcode := l.Get(-1)
|
||||
|
@ -80,7 +79,7 @@ func RunInput(input string) {
|
|||
exitcode = uint8(code)
|
||||
}
|
||||
|
||||
hooks.Em.Emit("command.exit", exitcode)
|
||||
cmdFinish(exitcode, cmdString)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -98,22 +97,22 @@ func RunInput(input string) {
|
|||
if syntax.IsIncomplete(err) || strings.HasSuffix(input, "\\") {
|
||||
continue
|
||||
} else if code, ok := interp.IsExitStatus(err); ok {
|
||||
hooks.Em.Emit("command.exit", code)
|
||||
cmdFinish(code, cmdString)
|
||||
} else if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
hooks.Em.Emit("command.exit", 1)
|
||||
cmdFinish(1, cmdString)
|
||||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if code, ok := interp.IsExitStatus(err); ok {
|
||||
hooks.Em.Emit("command.exit", code)
|
||||
cmdFinish(code, cmdString)
|
||||
} else {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hooks.Em.Emit("command.exit", 0)
|
||||
cmdFinish(0, cmdString)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,20 +128,32 @@ func execCommand(cmd string) error {
|
|||
_, argstring := splitInput(strings.Join(args, " "))
|
||||
|
||||
// If alias was found, use command alias
|
||||
if aliases[args[0]] != "" {
|
||||
for aliases[args[0]] != "" {
|
||||
alias := aliases[args[0]]
|
||||
argstring = alias + strings.TrimPrefix(argstring, args[0])
|
||||
cmdArgs, _ := splitInput(argstring)
|
||||
args = cmdArgs
|
||||
|
||||
if aliases[args[0]] == alias {
|
||||
break
|
||||
}
|
||||
if aliases[args[0]] != "" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
err := l.CallByParam(lua.P{
|
||||
Fn: commands[args[0]],
|
||||
NRet: 1,
|
||||
Protect: true,
|
||||
}, luar.New(l, args[1:]))
|
||||
}, luacmdArgs)
|
||||
luaexitcode := l.Get(-1)
|
||||
var exitcode uint8 = 0
|
||||
|
||||
|
@ -156,7 +167,7 @@ func execCommand(cmd string) error {
|
|||
fmt.Fprintln(os.Stderr,
|
||||
"Error in command:\n\n" + err.Error())
|
||||
}
|
||||
hooks.Em.Emit("command.exit", exitcode)
|
||||
cmdFinish(exitcode, argstring)
|
||||
return interp.NewExitStatus(exitcode)
|
||||
}
|
||||
|
||||
|
@ -229,3 +240,6 @@ func splitInput(input string) ([]string, 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
|
||||
var (
|
||||
requirePaths = commonRequirePaths + `
|
||||
.. ';/usr/share/hilbish/libs/?/init.lua;'
|
||||
.. ';/usr/share/hilbish/libs/?/?.lua;'` + linuxUserPaths
|
||||
requirePaths = commonRequirePaths + `.. ';'
|
||||
.. hilbish.dataDir .. '/libs/?/init.lua;'
|
||||
.. hilbish.dataDir .. '/libs/?/?.lua;'` + linuxUserPaths
|
||||
linuxUserPaths = `
|
||||
.. hilbish.xdg.data .. '/hilbish/libs/?/init.lua;'
|
||||
.. hilbish.xdg.data .. '/hilbish/libs/?/?.lua;'
|
||||
.. hilbish.xdg.data .. '/hilbish/libs/?.lua'
|
||||
.. hilbish.xdg.config .. '/hilbish/?/init.lua'
|
||||
.. hilbish.xdg.config .. '/hilbish/?/?.lua'
|
||||
.. hilbish.xdg.data .. '/hilbish/libs/?.lua;'
|
||||
.. hilbish.xdg.config .. '/hilbish/?/init.lua;'
|
||||
.. hilbish.xdg.config .. '/hilbish/?/?.lua;'
|
||||
.. hilbish.xdg.config .. '/hilbish/?.lua'`
|
||||
dataDir = "/usr/share/hilbish"
|
||||
preloadPath = dataDir + "/preload.lua"
|
||||
|
|
Loading…
Reference in New Issue