mirror of https://github.com/Hilbis/Hilbish
fix: dont complete binaries in path if complete req starts with file prefix
parent
88fd6f01b9
commit
59963add14
23
rl.go
23
rl.go
|
@ -60,17 +60,22 @@ func newLineReader(prompt string) *lineReader {
|
||||||
ctx = aliases.Resolve(ctx)
|
ctx = aliases.Resolve(ctx)
|
||||||
|
|
||||||
if len(fields) == 1 {
|
if len(fields) == 1 {
|
||||||
fileCompletions := fileComplete(query, ctx, fields)
|
prefixes := []string{"./", "../", "/", "~/"}
|
||||||
if len(fileCompletions) != 0 {
|
for _, prefix := range prefixes {
|
||||||
for _, f := range fileCompletions {
|
if strings.HasPrefix(query, prefix) {
|
||||||
name := strings.Replace(query + f, "~", curuser.HomeDir, 1)
|
fileCompletions := fileComplete(query, ctx, fields)
|
||||||
if info, err := os.Stat(name); err == nil && info.Mode().Perm() & 0100 == 0 {
|
if len(fileCompletions) != 0 {
|
||||||
continue
|
for _, f := range fileCompletions {
|
||||||
|
name := strings.Replace(query + f, "~", curuser.HomeDir, 1)
|
||||||
|
if info, err := os.Stat(name); err == nil && info.Mode().Perm() & 0100 == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
completions = append(completions, f)
|
||||||
|
}
|
||||||
|
compGroup[0].Suggestions = completions
|
||||||
}
|
}
|
||||||
completions = append(completions, f)
|
return "", compGroup
|
||||||
}
|
}
|
||||||
compGroup[0].Suggestions = completions
|
|
||||||
return "", compGroup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter out executables, but in path
|
// filter out executables, but in path
|
||||||
|
|
Loading…
Reference in New Issue