Compare commits

..

17 Commits

Author SHA1 Message Date
TorchedSammy 9165e0bdf9
chore: prepare for 1.0.1 release 2022-03-06 17:23:44 -04:00
TorchedSammy ec886e17fa
fix: dont refresh prompt at startup 2022-03-06 17:20:41 -04:00
TorchedSammy ba67278fad
fix: dont print types of args in appendPath 2022-03-06 17:19:47 -04:00
TorchedSammy 539cf402ca
fix: dont double set prompt 2022-03-06 17:08:53 -04:00
TorchedSammy 8eb5a6710d
build: update makefile 2022-03-06 15:12:10 -04:00
TorchedSammy 03795e5727
ci: update version of go-release-action 2022-03-06 15:04:45 -04:00
TorchedSammy 7959a8b572
docs: mention latest changes in changelog 2022-03-06 15:00:43 -04:00
TorchedSammy 5c4335ec6a
docs: include guide command in greeting message 2022-03-06 14:56:04 -04:00
TorchedSammy 99c9e95eeb
refactor!: change preload.lua to prelude/init.lua, add guide command
this commit has 2 changes:
- preload.lua is now init.lua in the prelude folder. the reason
for the name change of preload to prelude is to make update/
overwrite not hell

- the guide command has been added which is a simple step through
getting started type of thing for new users
2022-03-06 14:45:06 -04:00
TorchedSammy 46ef8ad122
ci: add name for release action 2022-03-06 14:44:28 -04:00
TorchedSammy cec6287e07
ci: add action to make release 2022-03-06 14:40:02 -04:00
TorchedSammy 4364031b16
fix!: change config path when custom config dir is used to be init.lua instead of .hilbishrc.lua 2022-03-06 14:39:23 -04:00
TorchedSammy 4ef6c7d5c0
fix: hilbish.read overriding history 2022-03-06 14:38:27 -04:00
TorchedSammy 764e2372a2
feat(ansikit): add screenMain and screenAlt functions to switch terminal screen 2022-03-06 14:26:28 -04:00
TorchedSammy fb3cedb161
fix: set prompt in hilbish.read 2022-03-06 14:23:41 -04:00
TorchedSammy ef6bf24cda
fix: finish command properly when sh error occurs 2022-03-06 13:32:39 -04:00
TorchedSammy 639bd09d0e
fix: import util 2022-03-06 13:31:50 -04:00
15 changed files with 145 additions and 25 deletions

40
.github/workflows/release.yml vendored 100644
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
View File

@ -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())

View File

@ -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)
}
}

View File

@ -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
View File

@ -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 {

View File

@ -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()

View File

@ -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 = { }

14
rl.go
View File

@ -15,8 +15,11 @@ 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()
// 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 {
@ -24,6 +27,7 @@ func newLineReader(prompt string) *lineReader {
}
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("")
}
}

View File

@ -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
)

View File

@ -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
)

View File

@ -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
)

View File

@ -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
)