Skip to content

Comment on Carapace: A multi-shell completion library and binaryparent

Comments

Unable to edit, but this is how I handled lazy loading the completions

    {
      # load compinit and rebind ^I (tab) to expand-or-complete, then compile
      # completions as bytecode if needed.
      lazyload-compinit() {
        autoload -Uz compinit
        # compinit will automatically cache completions to ~/.zcompdump
        compinit
        bindkey "^I" expand-or-complete
        {
          zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
          # if zcompdump file exists, and we don't have a compiled version or the
          # dump file is newer than the compiled file, update the bytecode.
          if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
            zcompile "$zcompdump"
          fi
        } &!
        # pretend we called this directly, instead of the lazy loader
        zle expand-or-complete
      }
      # mark the function as a zle widget
      zle -N lazyload-compinit
      bindkey "^I" lazyload-compinit
    }
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.