dim-an / cod

cod is a completion daemon for bash/fish/zsh
Apache License 2.0
517 stars 23 forks source link

fish shell support #37

Closed lordlycastle closed 3 years ago

lordlycastle commented 3 years ago

When you do cod init --help it lists that you can specify fish as an argument but no script is returned when fish is used.

So does this tool have FISH shell support? If not I would like to request it as it is very popular shell.

Thanks!

dim-an commented 3 years ago

First version of cod supported fish since it was shell on my local machine those days.

But then I decided to focus my efforts on zsh and bash (and switched to zsh myself).

Anyway a agree support of fish should be added.

lordlycastle commented 3 years ago

Awesome. So what is needed for this? How does this work? Do we need a hook to feed it all the commands we run and it filters for anything with -h|--help? Or does it read the history file?

Would help in any way I can!

dim-an commented 3 years ago

You can take a look at existing implementation for bash.

We need to implement an interface ShellScriptGenerator that generates a bunch of shell code.

First of all we need a hook that is launched after command execution (check __cod_postexec_bash). This hook:

About GeneratesCompletions. This script doesn't actually feeds shell with bunch of learned flags. Instead it asks shell to use cod api complete-words to get required completions. This api call unifies completion generation for all shells and can do complex logic while generating list of completions.