summaryrefslogtreecommitdiff
path: root/complete.go
diff options
context:
space:
mode:
Diffstat (limited to 'complete.go')
-rw-r--r--complete.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/complete.go b/complete.go
index 0a4e9f6..d085d5e 100644
--- a/complete.go
+++ b/complete.go
@@ -202,6 +202,25 @@ func parseArgv(argname string) *Auto {
}
}
+ // complete -C /usr/bin/argv forge sets:
+ // * `COMP_LINE`: A string containing the entire current command line (forge first second third forth ). This is what you are looking for.
+ // * `COMP_POINT`: A number indicating the cursor's position (index) within the COMP_LINE.
+ // * `COMP_WORDS`: An array in Bash (seen differently by Go) containing each individual word on the command line.
+ // * `COMP_CWORD`: A number indicating the index of the word the cursor is currently on within the COMP_WORDS array.
+ if len(os.Args) > 1 && os.Args[1] == pb.Argname {
+ pb.IsAuto = true
+ parts := strings.Split(os.Getenv("COMP_LINE"), " ")
+ pb.Debug = true
+ log.Fprintf(os.Stderr, "\n")
+ pb.Debugf("MATCH Partial os.Args=%v COMP_LINE=%v", os.Args, os.Getenv("COMP_LINE"))
+ log.Fprintf(os.Stdout, "jcarr")
+ if len(parts) > 0 {
+ pb.Arg0 = parts[0]
+ }
+ pb.Arg1 = os.Args[1]
+ os.Exit(0)
+ }
+
// should we do auto complete here?
if len(os.Args) > 1 && os.Args[1] == "--auto-complete" {
pb.IsAuto = true