home.social

#compdef — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #compdef, aggregated by home.social.

  1. So I see a lot of zsh completion scripts doing:

    #compdef _example example

    as s short form for

    #compdef example
    compdef _example example

    But looking at the documentation for my 5.9 version, this doesn't seem to be specified (and not needed?).

    The specifier

    #compdef example

    should be enough to mark the file autoloadable and the function defined in it will be called when completing 'example'.

    So is that indeed an old style?

    #Zsh

  2. @willhbr I'm researching how to write a generic installer command to install completion files for bash or zsh. If the zsh completion files begin with `#compdef name` and `#autoload` and are in `/usr/local/share/zsh/site-functions/`, they will automatically be loaded by zsh.

  3. Ah ha, I figured out how to load bash completions into zsh:

    1. The completion file name must start with with a `_` character.
    2. The completion file must be installed into `/usr/local/share/zsh/site-functions/`.
    3. The completion file must start with the lines `#compdef command-name-here`.
    4. You must enable and call the `compinit` and `bashcompinit` modules/commands in your `~/.zshrc`.

    If any of those things are missing, the completions won't load/work.
    #zsh #bashcompletion