Compare commits

..

No commits in common. "9165e0bdf9033f217c86f88871a96bfdb4bf281d" and "4b57dc2ed887655ac91e36da3b1250e88e16a479" have entirely different histories.

15 changed files with 25 additions and 145 deletions

View File

@ -1,40 +0,0 @@
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) local function doPrompt(fail, mode)
hilbish.prompt(lunacolors.format( hilbish.prompt(lunacolors.format(
'{blue}%u {cyan}%d\n' .. (fail and '{red}' or '{green}') .. '' '{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. ''
)) ))
end end

View File

@ -1,11 +1,6 @@
# 🎀 Changelog # 🎀 Changelog
## [1.0.1] - 2021-03-06 ## [1.0.0] - 2021-03-05
### 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 ### Added
- MacOS is now officialy supported, default compile time vars have been added - MacOS is now officialy supported, default compile time vars have been added
for it for it
@ -24,10 +19,6 @@ it finds the path to `binName` in $PATH
- Changing Vim mode throws a `hilbish.vimMode` hook - Changing Vim mode throws a `hilbish.vimMode` hook
- The current Vim mode is also accessible with the `hilbish.vimMode` property - The current Vim mode is also accessible with the `hilbish.vimMode` property
- Print errors in `hilbish.timeout()` and `hilbish.goro()` callbacks - 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 ### Fixed
- Tab completion for executables - Tab completion for executables
@ -42,8 +33,6 @@ to the terminal's main and alt buffer respectively
- Add full command to history in the case of incomplete input - Add full command to history in the case of incomplete input
- `hilbish.exec()` now has a windows substitute - `hilbish.exec()` now has a windows substitute
- Fixed case of successful command after prompted for more input not writing to history - 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 ### Changed
- The minimal config is truly minimal now - The minimal config is truly minimal now
@ -378,7 +367,6 @@ This input for example will prompt for more input to complete:
First "stable" release of Hilbish. 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 [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.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 [0.7.0]: https://github.com/Rosettea/Hilbish/compare/v0.6.1...v0.7.0

View File

@ -12,7 +12,7 @@ dev:
install: install:
@install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish" @install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish"
@mkdir -p "$(DESTDIR)$(LIBDIR)" @mkdir -p "$(DESTDIR)$(LIBDIR)"
@cp libs docs emmyLuaDocs prelude .hilbishrc.lua "$(DESTDIR)$(LIBDIR)" -r @cp libs docs preload.lua .hilbishrc.lua "$(DESTDIR)$(LIBDIR)" -r
@grep "$(DESTDIR)$(BINDIR)/hilbish" -qxF /etc/shells || echo "$(DESTDIR)$(BINDIR)/hilbish" >> /etc/shells @grep "$(DESTDIR)$(BINDIR)/hilbish" -qxF /etc/shells || echo "$(DESTDIR)$(BINDIR)/hilbish" >> /etc/shells
@echo "Hilbish Installed" @echo "Hilbish Installed"
@ -28,4 +28,4 @@ clean:
all: build install all: build install
.PHONY: install uninstall build dev clean .PHONY: install uninstall build dev hilbiline clean

5
api.go
View File

@ -50,7 +50,6 @@ func hilbishLoader(L *lua.LState) int {
greeting = `Welcome to {magenta}Hilbish{reset}, {cyan}` + curuser.Username + `{reset}. greeting = `Welcome to {magenta}Hilbish{reset}, {cyan}` + curuser.Username + `{reset}.
The nice lil shell for {blue}Lua{reset} fanatics! The nice lil shell for {blue}Lua{reset} fanatics!
Check out the {blue}{bold}guide{reset} command to get started.
` `
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
@ -207,8 +206,7 @@ func getenv(key, fallback string) string {
// --- @param prompt string // --- @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("", true) lualr := newLineReader(luaprompt)
lualr.SetPrompt(luaprompt)
input, err := lualr.Read() input, err := lualr.Read()
if err != nil { if err != nil {
@ -265,6 +263,7 @@ func hlalias(L *lua.LState) int {
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)
fmt.Println(arg.Type())
if arg.Type() == lua.LTTable { if arg.Type() == lua.LTTable {
arg.(*lua.LTable).ForEach(func(k lua.LValue, v lua.LValue) { arg.(*lua.LTable).ForEach(func(k lua.LValue, v lua.LValue) {
appendPath(v.String()) appendPath(v.String())

View File

@ -8,8 +8,6 @@ import (
"strings" "strings"
"time" "time"
"hilbish/util"
"github.com/yuin/gopher-lua" "github.com/yuin/gopher-lua"
"mvdan.cc/sh/v3/shell" "mvdan.cc/sh/v3/shell"
//"github.com/yuin/gopher-lua/parse" //"github.com/yuin/gopher-lua/parse"
@ -72,7 +70,6 @@ func runInput(input, origInput string) {
if code, ok := interp.IsExitStatus(err); ok { if code, ok := interp.IsExitStatus(err); ok {
cmdFinish(code, cmdString, origInput) cmdFinish(code, cmdString, origInput)
} else { } else {
cmdFinish(126, cmdString, origInput)
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
} }
} }

View File

@ -135,15 +135,6 @@ ansikit.saveState = function()
return ansikit.printCode(7) return ansikit.printCode(7)
end 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) ansikit.setTitle = function(text)
return ansikit.printCode(']2;' .. text, true) return ansikit.printCode(']2;' .. text, true)
end end

2
lua.go
View File

@ -51,7 +51,7 @@ func luaInit() {
// Add more paths that Lua can require from // Add more paths that Lua can require from
l.DoString("package.path = package.path .. " + requirePaths) l.DoString("package.path = package.path .. " + requirePaths)
err := l.DoFile("prelude/init.lua") err := l.DoFile("preload.lua")
if err != nil { if err != nil {
err = l.DoFile(preloadPath) err = l.DoFile(preloadPath)
if err != nil { if err != nil {

View File

@ -55,7 +55,7 @@ func main() {
defaultConfPath = filepath.Join(confDir, "hilbish", "init.lua") defaultConfPath = filepath.Join(confDir, "hilbish", "init.lua")
} else { } else {
// else do ~ substitution // else do ~ substitution
defaultConfPath = filepath.Join(strings.Replace(defaultConfDir, "~", homedir, 1), "init.lua") defaultConfPath = filepath.Join(strings.Replace(defaultConfDir, "~", homedir, 1), ".hilbishrc.lua")
} }
if defaultHistDir == "" { if defaultHistDir == "" {
defaultHistPath = filepath.Join(userDataDir, "hilbish", ".hilbish-history") defaultHistPath = filepath.Join(userDataDir, "hilbish", ".hilbish-history")
@ -114,7 +114,7 @@ func main() {
go handleSignals() go handleSignals()
luaInit() luaInit()
lr = newLineReader("", false) lr = newLineReader("")
// If user's config doesn't exixt, // If user's config doesn't exixt,
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath { if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
// Read default from current directory // Read default from current directory
@ -163,9 +163,9 @@ func main() {
os.Exit(0) os.Exit(0)
} }
initialized = true
input: input:
for interactive { for interactive {
lr.SetPrompt(fmtPrompt(prompt))
running = false running = false
input, err := lr.Read() input, err := lr.Read()

View File

@ -1,5 +1,4 @@
-- The preload file initializes everything else for our shell -- The preload file initializes everything else for our shell
local ansikit = require 'ansikit'
local bait = require 'bait' local bait = require 'bait'
local commander = require 'commander' local commander = require 'commander'
local fs = require 'fs' local fs = require 'fs'
@ -139,55 +138,6 @@ Available sections: ]]
print(table.concat(modules, ', ')) print(table.concat(modules, ', '))
end) 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 do
local virt_G = { } local virt_G = { }

26
rl.go
View File

@ -15,19 +15,15 @@ type lineReader struct {
var fileHist *fileHistory var fileHist *fileHistory
// other gophers might hate this naming but this is local, shut up // other gophers might hate this naming but this is local, shut up
func newLineReader(prompt string, noHist bool) *lineReader { func newLineReader(prompt string) *lineReader {
rl := readline.NewInstance() rl := readline.NewInstance()
// we don't mind hilbish.read rl instances having completion, fh, err := newFileHistory()
// but it cant have shared history fileHist = fh // go stupid
if !noHist { if err != nil {
fh, err := newFileHistory() panic(err)
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.ShowVimMode = false
rl.ViModeCallback = func(mode readline.ViMode) { rl.ViModeCallback = func(mode readline.ViMode) {
modeStr := "" modeStr := ""
@ -188,17 +184,17 @@ func (lr *lineReader) Read() (string, error) {
return s, err // might get another error return s, err // might get another error
} }
func (lr *lineReader) SetPrompt(p string) { func (lr *lineReader) SetPrompt(prompt string) {
halfPrompt := strings.Split(p, "\n") halfPrompt := strings.Split(prompt, "\n")
if len(halfPrompt) > 1 { if len(halfPrompt) > 1 {
lr.rl.Multiline = true lr.rl.Multiline = true
lr.rl.SetPrompt(strings.Join(halfPrompt[:len(halfPrompt) - 1], "\n")) lr.rl.SetPrompt(strings.Join(halfPrompt[:len(halfPrompt) - 1], "\n"))
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0] lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
} else { } else {
lr.rl.Multiline = false lr.rl.Multiline = false
lr.rl.SetPrompt(p) lr.rl.SetPrompt(prompt)
} }
if initialized && !running { if !running {
lr.rl.RefreshPromptInPlace("") lr.rl.RefreshPromptInPlace("")
} }
} }

View File

@ -2,7 +2,7 @@ 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 (
version = "v1.0.1" version = "v1.0.0"
defaultConfDir = "" // ~ will be substituted for home, path for user's default config defaultConfDir = "" // ~ will be substituted for home, path for user's default config
defaultHistDir = "" defaultHistDir = ""
commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'" commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'"
@ -17,6 +17,5 @@ var (
interactive bool interactive bool
login bool // Are we the login shell? login bool // Are we the login shell?
noexecute bool // Should we run Lua or only report syntax errors 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;'
.. hilbish.userDir.config .. '/hilbish/?.lua'` .. hilbish.userDir.config .. '/hilbish/?.lua'`
dataDir = "/usr/local/share/hilbish" dataDir = "/usr/local/share/hilbish"
preloadPath = dataDir + "/prelude/init.lua" preloadPath = dataDir + "/preload.lua"
sampleConfPath = dataDir + "/.hilbishrc.lua" // Path to default/sample config 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;'
.. hilbish.userDir.config .. '/hilbish/?.lua'` .. hilbish.userDir.config .. '/hilbish/?.lua'`
dataDir = "/usr/share/hilbish" dataDir = "/usr/share/hilbish"
preloadPath = dataDir + "/prelude/init.lua" preloadPath = dataDir + "/preload.lua"
sampleConfPath = dataDir + "/.hilbishrc.lua" // Path to default/sample config 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;'
.. hilbish.userDir.config .. '\\Hilbish\\libs\\?.lua;'` .. hilbish.userDir.config .. '\\Hilbish\\libs\\?.lua;'`
dataDir = "~\\Appdata\\Roaming\\Hilbish" // ~ and \ gonna cry? dataDir = "~\\Appdata\\Roaming\\Hilbish" // ~ and \ gonna cry?
preloadPath = dataDir + "\\prelude\\init.lua" preloadPath = dataDir + "\\preload.lua"
sampleConfPath = dataDir + "\\hilbishrc.lua" // Path to default/sample config sampleConfPath = dataDir + "\\hilbishrc.lua" // Path to default/sample config
) )