xc icon indicating copy to clipboard operation
xc copied to clipboard

Fish Completions

Open johnallen3d opened this issue 1 year ago • 4 comments

When I try to use tab completions in Fish shell I see the following (Go lang) error:

xc despanic: COMP_POINT env should be integer, got:
                                                                                           
goroutine 1 [running]:
github.com/posener/complete/v2.Complete({0x1042e5481, 0x2}, {0x1043bfa00, 0x140000927a0})
        github.com/posener/complete/[email protected]/complete.go:79 +0x364
github.com/posener/complete/v2.(*Command).Complete(...)
        github.com/posener/complete/[email protected]/command.go:20
main.runMain()
        github.com/joerdav/xc/cmd/xc/main.go:186 +0x138
main.main()
        github.com/joerdav/xc/cmd/xc/main.go:39 +0x1c

note: xc des was existing text when I hit Tab

johnallen3d avatar Sep 15 '24 22:09 johnallen3d

Thanks @johnallen3d ! I'll get fish installed and chase this one down, I'm using a separate package for completion so might take a little bit of digging!

joerdav avatar Sep 16 '24 08:09 joerdav

Sorry for the less than ideal solution for now while I look into fixing this:

Please set your ~/.config/fish/completions/xc.fish to:

function __complete_xc
    set -lx COMP_POINT (commandline -C)
    set -lx COMP_LINE (commandline -cp)
    test -z (commandline -ct)
    and set COMP_LINE "$COMP_LINE "
    /Users/joe/go/bin/xc <<<< REPLACE WITH YOUR INSTALL LOCATION
end
complete -f -c xc -a "(__complete_xc)"

joerdav avatar Sep 17 '24 15:09 joerdav

Thank you @joerdav! This is working for me. I've been bouncing between a machine with Bash and my local machine with Fish and keep forgetting not to use completion locally. 😁

johnallen3d avatar Sep 17 '24 17:09 johnallen3d

I need to replace the completion engine I think, seems to have been abandoned. Cobra seems good I think that would be a breaking change since it supports only double-dash flag names!

joerdav avatar Sep 17 '24 17:09 joerdav