mirror of https://github.com/Hilbis/Hilbish
Compare commits
17 Commits
4b57dc2ed8
...
9165e0bdf9
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 9165e0bdf9 | |
TorchedSammy | ec886e17fa | |
TorchedSammy | ba67278fad | |
TorchedSammy | 539cf402ca | |
TorchedSammy | 8eb5a6710d | |
TorchedSammy | 03795e5727 | |
TorchedSammy | 7959a8b572 | |
TorchedSammy | 5c4335ec6a | |
TorchedSammy | 99c9e95eeb | |
TorchedSammy | 46ef8ad122 | |
TorchedSammy | cec6287e07 | |
TorchedSammy | 4364031b16 | |
TorchedSammy | 4ef6c7d5c0 | |
TorchedSammy | 764e2372a2 | |
TorchedSammy | fb3cedb161 | |
TorchedSammy | ef6bf24cda | |
TorchedSammy | 639bd09d0e |
|
@ -0,0 +1,40 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]+.*
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: taiki-e/create-gh-release-action@v1
|
||||
with:
|
||||
title: Hilbish $tag
|
||||
changelog: CHANGELOG.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
releases-matrix:
|
||||
name: Build Release Binary
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
goos: [linux, windows, darwin]
|
||||
goarch: ["386", amd64, arm64]
|
||||
exclude:
|
||||
- goarch: "386"
|
||||
goos: darwin
|
||||
- goarch: arm64
|
||||
goos: windows
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: wangyoucao577/go-release-action@v1.25
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
goos: ${{ matrix.goos }}
|
||||
goarch: ${{ matrix.goarch }}
|
||||
binary_name: hilbish
|
||||
extra_files: LICENSE README.md CHANGELOG.md .hilbishrc.lua prelude docs emmyLuaDocs
|
|
@ -5,7 +5,7 @@ local ansikit = require 'ansikit'
|
|||
|
||||
local function doPrompt(fail, mode)
|
||||
hilbish.prompt(lunacolors.format(
|
||||
'{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. '∆ '
|
||||
'{blue}%u {cyan}%d\n' .. (fail and '{red}' or '{green}') .. '∆ '
|
||||
))
|
||||
end
|
||||
|
||||
|
|
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,6 +1,11 @@
|
|||
# 🎀 Changelog
|
||||
|
||||
## [1.0.0] - 2021-03-05
|
||||
## [1.0.1] - 2021-03-06
|
||||
### Fixed
|
||||
- Using `hilbish.appendPath` will no longer result in string spam (debugging thing left being)
|
||||
- Prompt gets set properly on startup
|
||||
|
||||
## [1.0.0] - 2021-03-06
|
||||
### Added
|
||||
- MacOS is now officialy supported, default compile time vars have been added
|
||||
for it
|
||||
|
@ -19,6 +24,10 @@ it finds the path to `binName` in $PATH
|
|||
- Changing Vim mode throws a `hilbish.vimMode` hook
|
||||
- The current Vim mode is also accessible with the `hilbish.vimMode` property
|
||||
- Print errors in `hilbish.timeout()` and `hilbish.goro()` callbacks
|
||||
- `hilbish.exit` hook is thrown when Hilbish is going to exit
|
||||
- `hilbish.exitCode` property to get the exit code of the last executed command
|
||||
- `screenMain` and `screenAlt` functions have been added to Ansikit to switch
|
||||
to the terminal's main and alt buffer respectively
|
||||
|
||||
### Fixed
|
||||
- Tab completion for executables
|
||||
|
@ -33,6 +42,8 @@ it finds the path to `binName` in $PATH
|
|||
- Add full command to history in the case of incomplete input
|
||||
- `hilbish.exec()` now has a windows substitute
|
||||
- Fixed case of successful command after prompted for more input not writing to history
|
||||
- `command.exit` is thrown when sh input is incorrect and when command executed after continue
|
||||
prompt exits successfully
|
||||
|
||||
### Changed
|
||||
- The minimal config is truly minimal now
|
||||
|
@ -367,6 +378,7 @@ This input for example will prompt for more input to complete:
|
|||
|
||||
First "stable" release of Hilbish.
|
||||
|
||||
[1.0.1]: https://github.com/Rosettea/Hilbish/compare/v1.0.0...v1.0.1
|
||||
[1.0.0]: https://github.com/Rosettea/Hilbish/compare/v0.7.1...v1.0.0
|
||||
[0.7.1]: https://github.com/Rosettea/Hilbish/compare/v0.7.0...v0.7.1
|
||||
[0.7.0]: https://github.com/Rosettea/Hilbish/compare/v0.6.1...v0.7.0
|
||||
|
|
4
Makefile
4
Makefile
|
@ -12,7 +12,7 @@ dev:
|
|||
install:
|
||||
@install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish"
|
||||
@mkdir -p "$(DESTDIR)$(LIBDIR)"
|
||||
@cp libs docs preload.lua .hilbishrc.lua "$(DESTDIR)$(LIBDIR)" -r
|
||||
@cp libs docs emmyLuaDocs prelude .hilbishrc.lua "$(DESTDIR)$(LIBDIR)" -r
|
||||
@grep "$(DESTDIR)$(BINDIR)/hilbish" -qxF /etc/shells || echo "$(DESTDIR)$(BINDIR)/hilbish" >> /etc/shells
|
||||
@echo "Hilbish Installed"
|
||||
|
||||
|
@ -28,4 +28,4 @@ clean:
|
|||
|
||||
all: build install
|
||||
|
||||
.PHONY: install uninstall build dev hilbiline clean
|
||||
.PHONY: install uninstall build dev clean
|
||||
|
|
5
api.go
5
api.go
|
@ -50,6 +50,7 @@ func hilbishLoader(L *lua.LState) int {
|
|||
|
||||
greeting = `Welcome to {magenta}Hilbish{reset}, {cyan}` + curuser.Username + `{reset}.
|
||||
The nice lil shell for {blue}Lua{reset} fanatics!
|
||||
Check out the {blue}{bold}guide{reset} command to get started.
|
||||
`
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
|
@ -206,7 +207,8 @@ func getenv(key, fallback string) string {
|
|||
// --- @param prompt string
|
||||
func hlread(L *lua.LState) int {
|
||||
luaprompt := L.CheckString(1)
|
||||
lualr := newLineReader(luaprompt)
|
||||
lualr := newLineReader("", true)
|
||||
lualr.SetPrompt(luaprompt)
|
||||
|
||||
input, err := lualr.Read()
|
||||
if err != nil {
|
||||
|
@ -263,7 +265,6 @@ func hlalias(L *lua.LState) int {
|
|||
func hlappendPath(L *lua.LState) int {
|
||||
// check if dir is a table or a string
|
||||
arg := L.Get(1)
|
||||
fmt.Println(arg.Type())
|
||||
if arg.Type() == lua.LTTable {
|
||||
arg.(*lua.LTable).ForEach(func(k lua.LValue, v lua.LValue) {
|
||||
appendPath(v.String())
|
||||
|
|
3
exec.go
3
exec.go
|
@ -8,6 +8,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"hilbish/util"
|
||||
|
||||
"github.com/yuin/gopher-lua"
|
||||
"mvdan.cc/sh/v3/shell"
|
||||
//"github.com/yuin/gopher-lua/parse"
|
||||
|
@ -70,6 +72,7 @@ func runInput(input, origInput string) {
|
|||
if code, ok := interp.IsExitStatus(err); ok {
|
||||
cmdFinish(code, cmdString, origInput)
|
||||
} else {
|
||||
cmdFinish(126, cmdString, origInput)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,15 @@ ansikit.saveState = function()
|
|||
return ansikit.printCode(7)
|
||||
end
|
||||
|
||||
ansikit.screenMain = function()
|
||||
return ansikit.printCSI('?1049', 'l')
|
||||
end
|
||||
|
||||
ansikit.screenAlt = function()
|
||||
ansikit.cursorTo(0, 0)
|
||||
return ansikit.printCSI('?1049', 'h')
|
||||
end
|
||||
|
||||
ansikit.setTitle = function(text)
|
||||
return ansikit.printCode(']2;' .. text, true)
|
||||
end
|
||||
|
|
2
lua.go
2
lua.go
|
@ -51,7 +51,7 @@ func luaInit() {
|
|||
// Add more paths that Lua can require from
|
||||
l.DoString("package.path = package.path .. " + requirePaths)
|
||||
|
||||
err := l.DoFile("preload.lua")
|
||||
err := l.DoFile("prelude/init.lua")
|
||||
if err != nil {
|
||||
err = l.DoFile(preloadPath)
|
||||
if err != nil {
|
||||
|
|
6
main.go
6
main.go
|
@ -55,7 +55,7 @@ func main() {
|
|||
defaultConfPath = filepath.Join(confDir, "hilbish", "init.lua")
|
||||
} else {
|
||||
// else do ~ substitution
|
||||
defaultConfPath = filepath.Join(strings.Replace(defaultConfDir, "~", homedir, 1), ".hilbishrc.lua")
|
||||
defaultConfPath = filepath.Join(strings.Replace(defaultConfDir, "~", homedir, 1), "init.lua")
|
||||
}
|
||||
if defaultHistDir == "" {
|
||||
defaultHistPath = filepath.Join(userDataDir, "hilbish", ".hilbish-history")
|
||||
|
@ -114,7 +114,7 @@ func main() {
|
|||
|
||||
go handleSignals()
|
||||
luaInit()
|
||||
lr = newLineReader("")
|
||||
lr = newLineReader("", false)
|
||||
// If user's config doesn't exixt,
|
||||
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
||||
// Read default from current directory
|
||||
|
@ -163,9 +163,9 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
initialized = true
|
||||
input:
|
||||
for interactive {
|
||||
lr.SetPrompt(fmtPrompt(prompt))
|
||||
running = false
|
||||
|
||||
input, err := lr.Read()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
-- The preload file initializes everything else for our shell
|
||||
local ansikit = require 'ansikit'
|
||||
local bait = require 'bait'
|
||||
local commander = require 'commander'
|
||||
local fs = require 'fs'
|
||||
|
@ -138,6 +139,55 @@ Available sections: ]]
|
|||
print(table.concat(modules, ', '))
|
||||
end)
|
||||
|
||||
local helpTexts = {
|
||||
[[
|
||||
Hello there! Welcome to Hilbish, the comfy and nice little shell for
|
||||
Lua users and fans. Hilbish is configured with Lua, and its
|
||||
scripts are also in Lua. It also runs both Lua and shell script when
|
||||
interactive (aka normal usage).
|
||||
]],
|
||||
[[
|
||||
What does that mean for you, the user? It means that if you prefer to
|
||||
use Lua for scripting instead of shell script but still have ordinary
|
||||
shell usage for interactive use.
|
||||
]],
|
||||
[[
|
||||
If this is your first time using Hilbish and Lua, check out the
|
||||
Programming in Lua book here: https://www.lua.org/pil
|
||||
After (or if you already know Lua) check out the doc command.
|
||||
It is an in shell tool for documentation about Hilbish provided
|
||||
functions and modules.
|
||||
]],
|
||||
[[
|
||||
If you've updated from a pre-1.0 version (0.7.1 as an example)
|
||||
you'll want to move your config from ~/.hilbishrc.lua to
|
||||
]] ..
|
||||
hilbish.userDir.config .. '/hilbish/init.lua' ..
|
||||
[[
|
||||
|
||||
and also change all global functions (prompt, alias) to be
|
||||
in the hilbish module (hilbish.prompt, hilbish.alias as examples).
|
||||
|
||||
Since 1.0 is a big release, you'll want to check the changelog
|
||||
at https://github.com/Rosettea/Hilbish/releases/tag/v1.0.0
|
||||
to find more breaking changes.
|
||||
]]
|
||||
}
|
||||
commander.register('guide', function()
|
||||
ansikit.clear()
|
||||
ansikit.cursorTo(0, 0)
|
||||
for _, text in ipairs(helpTexts) do
|
||||
print(text)
|
||||
local out = hilbish.read('Hit enter to continue ')
|
||||
ansikit.clear()
|
||||
ansikit.cursorTo(0, 0)
|
||||
if not out then
|
||||
return
|
||||
end
|
||||
end
|
||||
print 'Hope you enjoy using Hilbish!'
|
||||
end)
|
||||
|
||||
do
|
||||
local virt_G = { }
|
||||
|
26
rl.go
26
rl.go
|
@ -15,15 +15,19 @@ type lineReader struct {
|
|||
var fileHist *fileHistory
|
||||
|
||||
// other gophers might hate this naming but this is local, shut up
|
||||
func newLineReader(prompt string) *lineReader {
|
||||
func newLineReader(prompt string, noHist bool) *lineReader {
|
||||
rl := readline.NewInstance()
|
||||
fh, err := newFileHistory()
|
||||
fileHist = fh // go stupid
|
||||
if err != nil {
|
||||
panic(err)
|
||||
// we don't mind hilbish.read rl instances having completion,
|
||||
// but it cant have shared history
|
||||
if !noHist {
|
||||
fh, err := newFileHistory()
|
||||
fileHist = fh // go stupid
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
rl.SetHistoryCtrlR("file", fileHist)
|
||||
rl.HistoryAutoWrite = false
|
||||
}
|
||||
rl.SetHistoryCtrlR("file", fileHist)
|
||||
rl.HistoryAutoWrite = false
|
||||
rl.ShowVimMode = false
|
||||
rl.ViModeCallback = func(mode readline.ViMode) {
|
||||
modeStr := ""
|
||||
|
@ -184,17 +188,17 @@ func (lr *lineReader) Read() (string, error) {
|
|||
return s, err // might get another error
|
||||
}
|
||||
|
||||
func (lr *lineReader) SetPrompt(prompt string) {
|
||||
halfPrompt := strings.Split(prompt, "\n")
|
||||
func (lr *lineReader) SetPrompt(p string) {
|
||||
halfPrompt := strings.Split(p, "\n")
|
||||
if len(halfPrompt) > 1 {
|
||||
lr.rl.Multiline = true
|
||||
lr.rl.SetPrompt(strings.Join(halfPrompt[:len(halfPrompt) - 1], "\n"))
|
||||
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
|
||||
} else {
|
||||
lr.rl.Multiline = false
|
||||
lr.rl.SetPrompt(prompt)
|
||||
lr.rl.SetPrompt(p)
|
||||
}
|
||||
if !running {
|
||||
if initialized && !running {
|
||||
lr.rl.RefreshPromptInPlace("")
|
||||
}
|
||||
}
|
||||
|
|
3
vars.go
3
vars.go
|
@ -2,7 +2,7 @@ package main
|
|||
|
||||
// String vars that are free to be changed at compile time
|
||||
var (
|
||||
version = "v1.0.0"
|
||||
version = "v1.0.1"
|
||||
defaultConfDir = "" // ~ will be substituted for home, path for user's default config
|
||||
defaultHistDir = ""
|
||||
commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'"
|
||||
|
@ -17,5 +17,6 @@ var (
|
|||
interactive bool
|
||||
login bool // Are we the login shell?
|
||||
noexecute bool // Should we run Lua or only report syntax errors
|
||||
initialized bool
|
||||
)
|
||||
|
||||
|
|
|
@ -15,6 +15,6 @@ var (
|
|||
.. hilbish.userDir.config .. '/hilbish/?/?.lua;'
|
||||
.. hilbish.userDir.config .. '/hilbish/?.lua'`
|
||||
dataDir = "/usr/local/share/hilbish"
|
||||
preloadPath = dataDir + "/preload.lua"
|
||||
preloadPath = dataDir + "/prelude/init.lua"
|
||||
sampleConfPath = dataDir + "/.hilbishrc.lua" // Path to default/sample config
|
||||
)
|
||||
|
|
|
@ -15,6 +15,6 @@ var (
|
|||
.. hilbish.userDir.config .. '/hilbish/?/?.lua;'
|
||||
.. hilbish.userDir.config .. '/hilbish/?.lua'`
|
||||
dataDir = "/usr/share/hilbish"
|
||||
preloadPath = dataDir + "/preload.lua"
|
||||
preloadPath = dataDir + "/prelude/init.lua"
|
||||
sampleConfPath = dataDir + "/.hilbishrc.lua" // Path to default/sample config
|
||||
)
|
||||
|
|
|
@ -9,6 +9,6 @@ var (
|
|||
.. hilbish.userDir.config .. '\\Hilbish\\libs\\?\\?.lua;'
|
||||
.. hilbish.userDir.config .. '\\Hilbish\\libs\\?.lua;'`
|
||||
dataDir = "~\\Appdata\\Roaming\\Hilbish" // ~ and \ gonna cry?
|
||||
preloadPath = dataDir + "\\preload.lua"
|
||||
preloadPath = dataDir + "\\prelude\\init.lua"
|
||||
sampleConfPath = dataDir + "\\hilbishrc.lua" // Path to default/sample config
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue