add executable completion on windows
This commit is contained in:
1 parent
fef99c1d70
commit
e1b6d38386
3 files changed
+22
-2
No files matched your search
+3
-2
@@ -134,7 +134,7 @@ func matchWord(s string, words []string) (matches []string, longest string) {
|
||||
func matchExec(s string) (matches []string, longest string) {
|
||||
var words []string
|
||||
|
||||
paths := strings.Split(envPath, ":")
|
||||
paths := strings.Split(envPath, string(filepath.ListSeparator))
|
||||
|
||||
for _, p := range paths {
|
||||
if _, err := os.Stat(p); os.IsNotExist(err) {
|
||||
@@ -157,10 +157,11 @@ func matchExec(s string) (matches []string, longest string) {
|
||||
continue
|
||||
}
|
||||
|
||||
if !f.Mode().IsRegular() || f.Mode()&0111 == 0 {
|
||||
if !f.Mode().IsRegular() || !isExecutable(f) {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Print(f.Name())
|
||||
words = append(words, f.Name())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,3 +129,7 @@ func setDefaults() {
|
||||
func moveCursor(y, x int) {
|
||||
fmt.Printf("\033[%d;%dH", y, x)
|
||||
}
|
||||
|
||||
func isExecutable(f os.FileInfo) bool {
|
||||
return f.Mode()&0111 != 0
|
||||
}
|
||||
@@ -16,6 +16,10 @@ var (
|
||||
envShell = os.Getenv("SHELL")
|
||||
)
|
||||
|
||||
var (
|
||||
envPathExt = os.Getenv("PATHEXT")
|
||||
)
|
||||
|
||||
var (
|
||||
gDefaultShell = "cmd"
|
||||
gDefaultSocketProt = "tcp"
|
||||
@@ -109,3 +113,14 @@ func moveCursor(y, x int) {
|
||||
// TODO: implement
|
||||
return
|
||||
}
|
||||
|
||||
func isExecutable(f os.FileInfo) bool {
|
||||
exts := strings.Split(envPathExt, string(filepath.ListSeparator))
|
||||
for _, e := range exts {
|
||||
if strings.HasSuffix(strings.ToLower(f.Name()), strings.ToLower(e)) {
|
||||
log.Print(f.Name(), e)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in new issue
Block a user