Compare commits

..

No commits in common. "eb0a81f7a2e598f1c3339ed3cb2c937a231f87b3" and "8b5dc6995017cd530cb64c0d80873c54a9ee5235" have entirely different histories.

11 changed files with 25 additions and 93 deletions

View File

@ -1,21 +1,5 @@
# 🎀 Changelog
## [1.1.0] - 2021-03-17
### Added
- `hilbish.vimAction` hook (`doc vimMode actions`)
- `command.not-executable` hook (will replace `command.no-perm` in a future release)
### Fixed
- Check if interactive before adding to history
- Escape in vim mode exits all modes and not only insert
- Make 2nd line in prompt empty if entire prompt is 1 line
- Completion menu doesnt appear if there is only 1 result
- Ignore SIGQUIT, which caused a panic unhandled
- Remove hostname in greeting on Windows
- Handle PATH binaries properly on Windows
- Fix removal of dot in the beginning of folders/files that have them for file complete
- Fix prompt being set to the continue prompt even when exited
## [1.0.4] - 2021-03-12
### Fixed
- Panic when history directory doesn't exist
@ -408,7 +392,6 @@ This input for example will prompt for more input to complete:
First "stable" release of Hilbish.
[1.1.0]: https://github.com/Rosettea/Hilbish/compare/v1.0.4...v1.1.0
[1.0.4]: https://github.com/Rosettea/Hilbish/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/Rosettea/Hilbish/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/Rosettea/Hilbish/compare/v1.0.1...v1.0.2

View File

@ -33,7 +33,7 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) {
if len(fileCompletions) != 0 {
for _, f := range fileCompletions {
name := strings.Replace(query + f, "~", curuser.HomeDir, 1)
if err := findExecutable(name, false, true); err != nil {
if info, err := os.Stat(name); err == nil && info.Mode().Perm() & 0100 == 0 {
continue
}
completions = append(completions, f)
@ -51,8 +51,7 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) {
// get basename from matches
for _, match := range matches {
// check if we have execute permissions for our match
err := findExecutable(match, true, false)
if err != nil {
if info, err := os.Stat(match); err == nil && info.Mode().Perm() & 0100 == 0 {
continue
}
// get basename from match
@ -94,7 +93,7 @@ func matchPath(path, pref string) ([]string, error) {
for _, match := range matches {
name := filepath.Base(match)
p := filepath.Base(pref)
if pref == "" || pref == "./" {
if pref == "" {
p = ""
}
name = strings.TrimPrefix(name, p)

View File

@ -1,16 +0,0 @@
Vim actions are essentially just when a user uses a Vim keybind.
Things like yanking and pasting are Vim actions.
This is not an "offical Vim thing," just a Hilbish thing.
The `hilbish.vimAction` hook is thrown whenever a Vim action occurs.
It passes 2 arguments: the action name, and an array (table) of args
relating to it.
Here is documentation for what the table of args will hold for an
appropriate Vim action.
- `yank`: register, yankedText
The first argument for the yank action is the register yankedText goes to.
- `paste`: register, pastedText
The first argument for the paste action is the register pastedText is taken from.

View File

@ -1,4 +0,0 @@
Hilbish has a Vim binding input mode accessible for use.
It can be enabled with the `hilbish.inputMode` function (check `doc hilbish`).
This is documentation for everything relating to it.

12
exec.go
View File

@ -6,7 +6,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"time"
@ -162,20 +161,15 @@ func execCommand(cmd, old string) error {
}
func lookpath(file string) error { // custom lookpath function so we know if a command is found *and* is executable
var skip []string
if runtime.GOOS == "windows" {
skip = []string{"./", "../", "~/", "C:"}
} else {
skip = []string{"./", "/", "../", "~/"}
}
skip := []string{"./", "/", "../", "~/"}
for _, s := range skip {
if strings.HasPrefix(file, s) {
return findExecutable(file, false, false)
return findExecutable(file)
}
}
for _, dir := range filepath.SplitList(os.Getenv("PATH")) {
path := filepath.Join(dir, file)
err := findExecutable(path, true, false)
err := findExecutable(path)
if err == errNotExec {
return err
} else if err == nil {

View File

@ -6,19 +6,13 @@ import (
"os"
)
func findExecutable(path string, inPath, dirs bool) error {
func findExecutable(path string) error {
f, err := os.Stat(path)
if err != nil {
return err
}
if dirs {
if m := f.Mode(); m & 0111 != 0 {
return nil
}
} else {
if m := f.Mode(); !m.IsDir() && m & 0111 != 0 {
return nil
}
if m := f.Mode(); !m.IsDir() && m & 0111 != 0 {
return nil
}
return errNotExec
}

View File

@ -7,30 +7,20 @@ import (
"os"
)
func findExecutable(path string, inPath, dirs bool) error {
func findExecutable(path string) error {
nameExt := filepath.Ext(path)
pathExts := filepath.SplitList(os.Getenv("PATHEXT"))
if inPath {
if nameExt == "" {
for _, ext := range pathExts {
_, err := os.Stat(path + ext)
if err == nil {
return nil
}
}
} else {
_, err := os.Stat(path)
if nameExt == "" {
for _, ext := range filepath.SplitList(os.Getenv("PATHEXT")) {
_, err := os.Stat(path + ext)
if err == nil {
if contains(pathExts, nameExt) { return nil }
return errNotExec
return nil
}
}
} else {
_, err := os.Stat(path)
if err == nil {
if contains(pathExts, nameExt) { return nil }
return errNotExec
}
}
_, err := os.Stat(path)
if err == nil {
return errNotExec
}
return os.ErrNotExist

11
main.go
View File

@ -198,8 +198,6 @@ input:
for {
input, err = continuePrompt(input)
if err != nil {
running = true
lr.SetPrompt(fmtPrompt(prompt))
goto input // continue inside nested loop
}
if !strings.HasSuffix(input, "\\") {
@ -286,12 +284,3 @@ func removeDupes(slice []string) []string {
return newSlice
}
func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}

View File

@ -263,7 +263,7 @@ bait.catch('command.not-found', function(cmd)
print(string.format('hilbish: %s not found', cmd))
end)
bait.catch('command.not-executable', function(cmd)
print(string.format('hilbish: %s: not executable', cmd))
bait.catch('command.no-perm', function(cmd)
print(string.format('hilbish: %s: no permission', cmd))
end)

View File

@ -96,6 +96,9 @@ func (rl *Instance) getTabSearchCompletion() {
// Set the hint for this completion mode
rl.hintText = append([]rune("Completion search: "), rl.tfLine...)
// Set the hint for this completion mode
rl.hintText = append([]rune("Completion search: "), rl.tfLine...)
for _, g := range rl.tcGroups {
g.updateTabFind(rl)
}

View File

@ -2,7 +2,7 @@ package main
// String vars that are free to be changed at compile time
var (
version = "v1.1.0"
version = "v1.0.4"
defaultConfDir = "" // ~ will be substituted for home, path for user's default config
defaultHistDir = ""
commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'"