Print command line completions by lihaohong6 · Pull Request #606 · boyter/scc

It depends on the shell (and possibly the operating system). I'm using Linux through WSL to experiment, so hopefully the procedure is more-or-less the same on macOS if that's what you use.

For zsh, which is what I usually use, I would

  1. Run ./scc completion --shell zsh > _scc to generate shell completions and pipe the output to a file. Underscore + name of executable is usually how zsh completion files are named.
  2. Run sudo cp _scc /usr/share/zsh/site-functions/_scc. This copies the completions file to the location where zsh completion scripts are stored. There are ways to have zsh load completion scripts without superuser privileges, but this is the easiest.
  3. Restart the shell.
  4. Type scc --no- and then press tab. Something along the lines of the screenshot below should appear.
    image

I have a bunch of zsh plugins, so hopefully this applies to a vanilla zsh experience too.

Other shells are pretty similar. For bash, the command would be ./scc completion --shell bash > scc.bash, and the file would be stored in /usr/share/bash-completion/completions. bash requires a double tab to autocomplete, and shows something similar. I haven't customized bash, so this should be easier to reproduce.

image

For fish, the command is ./scc completion --shell fish > scc.fish and the file location is /usr/share/fish/vendor_completions.d. My fish is a fresh install, so it should be easily reproducible.

image

Technically powershell is supported too, but I'm not familiar with that ecosystem. Since everything is autogenerated anyway, I would assume cobra did it correctly.