Search code examples
autocompletedigital-oceanfish

How can you get doctl completion working in fish shell?


doctl is the digitalocean cli tool for interfacing with digitalocean resources via CLI.

It has completion options built-in, for example you can run this command to enable bash completion

doctl completion bash > /etc/bash_completion.d/doctl

(may need to sudo tee the right side)

But I have been unable to figure out how to get autocompletion for fish shell working.

The doctl cli does not provide the syntax or example command.

I tried this, but it doesn't work

doctl completion fish > .config/fish/completions/doctl

Solution

  • I tried this, but it doesn't work doctl completion fish > .config/fish/completions/doctl

    You're almost right. The completion file needs to have a ".fish" extension:

    doctl completion fish > ~/.config/fish/completions/doctl.fish
    

    (also I added ~/ to make it an absolute path)