From 374bcd47a33fa8ae3af30860a9ef0c3ef9a815b1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 2 Oct 2025 15:17:54 -0500 Subject: thoughts on "complete -C argv forge" --- complete.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'complete.go') 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 -- cgit v1.2.3