mirror of
https://github.com/Hilbis/Hilbish
synced 2025-05-12 15:23:23 +00:00
Compare commits
8 Commits
e7c4b2dc16
...
149d3244e0
Author | SHA1 | Date | |
---|---|---|---|
149d3244e0 | |||
|
36ce05e85a | ||
ac7c97442e | |||
7fc3f4a569 | |||
dbb45a1947 | |||
3da150bb64 | |||
46968e632b | |||
eded38c7b5 |
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Skip over file and prevent panic if info cannot be retrieved during file completion (due to permission error or anything else)
|
||||||
|
|
||||||
|
## [2.3.3] - 2024-11-04
|
||||||
|
### Fixed
|
||||||
- Heredocs having issues
|
- Heredocs having issues
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -780,7 +784,8 @@ This input for example will prompt for more input to complete:
|
|||||||
|
|
||||||
First "stable" release of Hilbish.
|
First "stable" release of Hilbish.
|
||||||
|
|
||||||
[2.3.1]: https://github.com/Rosettea/Hilbish/compare/v2.3.1...v2.3.2
|
[2.3.3]: https://github.com/Rosettea/Hilbish/compare/v2.3.2...v2.3.3
|
||||||
|
[2.3.2]: https://github.com/Rosettea/Hilbish/compare/v2.3.1...v2.3.2
|
||||||
[2.3.1]: https://github.com/Rosettea/Hilbish/compare/v2.3.0...v2.3.1
|
[2.3.1]: https://github.com/Rosettea/Hilbish/compare/v2.3.0...v2.3.1
|
||||||
[2.3.0]: https://github.com/Rosettea/Hilbish/compare/v2.2.3...v2.3.0
|
[2.3.0]: https://github.com/Rosettea/Hilbish/compare/v2.2.3...v2.3.0
|
||||||
[2.2.3]: https://github.com/Rosettea/Hilbish/compare/v2.2.2...v2.2.3
|
[2.2.3]: https://github.com/Rosettea/Hilbish/compare/v2.2.2...v2.2.3
|
||||||
|
@ -157,9 +157,12 @@ func matchPath(query string) ([]string, string) {
|
|||||||
|
|
||||||
files, _ := os.ReadDir(path)
|
files, _ := os.ReadDir(path)
|
||||||
for _, entry := range files {
|
for _, entry := range files {
|
||||||
// should we handle errors here?
|
|
||||||
file, err := entry.Info()
|
file, err := entry.Info()
|
||||||
if err == nil && file.Mode() & os.ModeSymlink != 0 {
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if file.Mode() & os.ModeSymlink != 0 {
|
||||||
path, err := filepath.EvalSymlinks(filepath.Join(path, file.Name()))
|
path, err := filepath.EvalSymlinks(filepath.Join(path, file.Name()))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
file, err = os.Lstat(path)
|
file, err = os.Lstat(path)
|
||||||
|
2
go.mod
2
go.mod
@ -34,4 +34,4 @@ replace github.com/maxlandon/readline => ./readline
|
|||||||
|
|
||||||
replace layeh.com/gopher-luar => github.com/layeh/gopher-luar v1.0.10
|
replace layeh.com/gopher-luar => github.com/layeh/gopher-luar v1.0.10
|
||||||
|
|
||||||
replace github.com/arnodel/golua => github.com/Rosettea/golua v0.0.0-20240427174124-d239074c1749
|
replace github.com/arnodel/golua => github.com/Rosettea/golua v0.0.0-20241104031959-5551ea280f23
|
||||||
|
4
go.sum
4
go.sum
@ -1,5 +1,5 @@
|
|||||||
github.com/Rosettea/golua v0.0.0-20240427174124-d239074c1749 h1:jIFnWBTsYw8s7RX7H2AOXjDVhWP3ol7OzUVaPN2KnGI=
|
github.com/Rosettea/golua v0.0.0-20241104031959-5551ea280f23 h1:mUZnT0gmDEmTkqXsbnDbuJ3CNil7DCOMiCQYgjbKIdI=
|
||||||
github.com/Rosettea/golua v0.0.0-20240427174124-d239074c1749/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
|
github.com/Rosettea/golua v0.0.0-20241104031959-5551ea280f23/go.mod h1:9jzpYPiU2is0HVGCiuIOBSXdergHUW44IEjmuN1UrIE=
|
||||||
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20240815163633-562273e09b73 h1:zTTUJqNnrF2qf4LgygN8Oae5Uxn6ewH0hA8jyTCHfXw=
|
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20240815163633-562273e09b73 h1:zTTUJqNnrF2qf4LgygN8Oae5Uxn6ewH0hA8jyTCHfXw=
|
||||||
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20240815163633-562273e09b73/go.mod h1:YZalN5H7WNQw3DGij6IvHsEhn5YMW7M2FCwG6gnfKy4=
|
github.com/Rosettea/sh/v3 v3.4.0-0.dev.0.20240815163633-562273e09b73/go.mod h1:YZalN5H7WNQw3DGij6IvHsEhn5YMW7M2FCwG6gnfKy4=
|
||||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
|
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
local fs = require 'fs'
|
||||||
|
|
||||||
|
-- explanation: this specific function gives to us info about
|
||||||
|
-- the currently running source. this includes a path to the
|
||||||
|
-- source file (info.source)
|
||||||
|
-- we will use that to automatically load all commands by reading
|
||||||
|
-- all the files in this dir and just requiring it.
|
||||||
|
local info = debug.getinfo(1)
|
||||||
|
local commandDir = fs.dir(info.source)
|
||||||
|
if commandDir == '.' then return end
|
||||||
|
|
||||||
|
local commands = fs.readdir(commandDir)
|
||||||
|
for _, command in ipairs(commands) do
|
||||||
|
local name = command:gsub('%.lua', '') -- chop off extension
|
||||||
|
if name ~= 'init' then
|
||||||
|
-- skip this file (for obvious reasons)
|
||||||
|
require('nature.completions.' .. name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function hilbish.completion.handler(line, pos)
|
function hilbish.completion.handler(line, pos)
|
||||||
if type(line) ~= 'string' then error '#1 must be a string' end
|
if type(line) ~= 'string' then error '#1 must be a string' end
|
||||||
if type(pos) ~= 'number' then error '#2 must be a number' end
|
if type(pos) ~= 'number' then error '#2 must be a number' end
|
53
nature/completions/sudo.lua
Normal file
53
nature/completions/sudo.lua
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
local function curry(f)
|
||||||
|
return function (x) return function (y) return f(x,y) end end
|
||||||
|
end
|
||||||
|
|
||||||
|
local flags = {}
|
||||||
|
local function flag(f, description)
|
||||||
|
flags[f] = {description}
|
||||||
|
end
|
||||||
|
|
||||||
|
local addflag = curry(flag)
|
||||||
|
|
||||||
|
addflag '-A' 'Ask for password via askpass or $SUDO_ASKPASS'
|
||||||
|
addflag '-B' 'Ring the bell as part of the password prompt.'
|
||||||
|
|
||||||
|
hilbish.complete('command.sudo', function(query, ctx, fields)
|
||||||
|
table.remove(fields, 1)
|
||||||
|
local nonflags = table.filter(fields, function(v)
|
||||||
|
if v == '' then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return v:match '^%-' == nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
if #fields == 1 or #nonflags == 0 then
|
||||||
|
-- complete commands or sudo flags
|
||||||
|
if query:match ('^%-') then
|
||||||
|
local compFlags = {}
|
||||||
|
for flg, flgstuff in pairs(flags) do
|
||||||
|
if flg:match('^' .. query) then
|
||||||
|
compFlags[flg] = flgstuff
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local compGroup = {
|
||||||
|
items = compFlags,
|
||||||
|
type = 'list'
|
||||||
|
}
|
||||||
|
|
||||||
|
return {compGroup}, query
|
||||||
|
end
|
||||||
|
|
||||||
|
local comps, pfx = hilbish.completion.bins(query, ctx, fields)
|
||||||
|
local compGroup = {
|
||||||
|
items = comps,
|
||||||
|
type = 'grid'
|
||||||
|
}
|
||||||
|
|
||||||
|
return {compGroup}, pfx
|
||||||
|
end
|
||||||
|
|
||||||
|
-- otherwise, get command flags
|
||||||
|
return hilbish.completion.call('command.' .. fields[2], query, ctx, fields)
|
||||||
|
end)
|
@ -2,7 +2,9 @@ local bait = require 'bait'
|
|||||||
local lunacolors = require 'lunacolors'
|
local lunacolors = require 'lunacolors'
|
||||||
|
|
||||||
hilbish.motd = [[
|
hilbish.motd = [[
|
||||||
{magenta}Hilbish{reset} blooms in the {blue}midnight.{reset}
|
Wait ... {magenta}2.3{reset} is basically the same as {red}2.2?{reset}
|
||||||
|
Erm.. {blue}Ctrl-C works for Commanders,{reset} {cyan}and the sh runner has some fixes.{reset}
|
||||||
|
Just trust me bro, this is an important bug fix release. {red}- 🌺 sammyette{reset}
|
||||||
]]
|
]]
|
||||||
|
|
||||||
bait.catch('hilbish.init', function()
|
bait.catch('hilbish.init', function()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user