如何将这些不常见选项的 zplug 代码转换或翻译成 zinit 语言?

如何将这些不常见选项的 zplug 代码转换或翻译成 zinit 语言?

我阅读了文档,但我翻译的 zinit 代码不起作用。我发现他们的 zinit 文档非常混乱。

  1. 我不知道usezinit 语言中引用了哪个 zplug,例如:

    zplug "mafredri/zsh-async", from:github, use:async.zsh
    
    zplug "junegunn/fzf-bin", as:command, from:gh-r, rename-to:fzf, use:"*${(L)$(uname -s)}*amd64*"
    zplug "junegunn/fzf", use:"shell/*.zsh"
    zplug "peco/peco", as:command,     from:gh-r, use:"*${(L)$(uname -s)}*amd64*"
    

    我转换成zinit:

    zinit light "mafredri/zsh-async" pick "async.zsh"
    

    但它给出了一个错误:No such (plugin or snippet) directory: mafredri/zsh-async/pickasync.zsh。我对src和表示怀疑multisrc。我也不知道哪个类似rename-to。我认为是id-as,但我不确定。

  2. defer我在 zinit 语言中没有找到与 zplug 类似的选项:

    zplug "zdharma/fast-syntax-highlighting", defer:2
    

    我不确定使用它是否正确depth=2

  3. 我在 zinit 文档中找不到的另一个类似选项是hook-load

    zplug "larkery/zsh-histdb", use:"{sqlite-history,histdb-interactive}.zsh", hook-load:"histdb-update-outcome"
    
  4. 我会将多个插件转换为 zinit 的语法for,我不确定如何正确翻译:

    zplug "plugins/common-aliases",    from:oh-my-zsh
    zplug "plugins/copydir",           from:oh-my-zsh
    zplug "plugins/cp",                from:oh-my-zsh
    zplug "plugins/encode64",          from:oh-my-zsh
    zplug "plugins/extract",           from:oh-my-zsh
    zplug "plugins/git",               from:oh-my-zsh
    zplug "plugins/golang",            from:oh-my-zsh, if:"(( $+commands[go] ))"
    zplug "plugins/npm",               from:oh-my-zsh, if:"(( $+commands[npm] ))"
    zplug "plugins/sudo",              from:oh-my-zsh, if:"(( $+commands[sudo] ))"
    zplug "plugins/systemd",           from:oh-my-zsh, if:"(( $+commands[systemctl] ))"
    zplug "plugins/urltools",          from:oh-my-zsh
    zplug "tcnksm/docker-alias", use:zshrc
    

    我翻译成zinit:

       zinit wait lucid for \
          OMZ::plugins/common-aliases \
          OMZ::plugins/copydir \
          OMZ::plugins/cp \
          OMZ::plugins/encode64 \
          OMZ::plugins/extract \
          OMZ::plugins/git \
          OMZ::plugins/golang if "[[ $+commands[go] ]]" \
          OMZ::plugins/npm if "[[ $+commands[npm] ]]" \
          OMZ::plugins/sudo if "[[ $+commands[sudo] ]]" \
          OMZ::plugins/systemd if "[[ $+commands[systemd] ]]" \
          OMZ::plugins/urltools \
          OMZ::tcnksm/docker-alias pick "zshrc"
    
  5. 我还想知道是否有类似于zplug checkzinit 语言的类似选项,例如:

    if zplug check "junegunn/fzf-bin"; then
      export FZF_DEFAULT_OPTS="--height 40% --reverse --border --inline-info --color=dark,bg+:235,hl+:10,pointer:5"
    fi
    

答案1

  1. Zpluguse是 Zinit 的pickhttps://github.com/zdharma/zinit#selection-of-files-to-source-
  2. Zplugdefer是 Zinit 的waithttps://github.com/zdharma/zinit#conditional-loading
  3. Zplughook-load在 Zinit 中没有等效项,但您可以像这样解决它:
zinit light-mode for pick'sqlite-history.zsh' \
  atload'autoload -Uz add-zsh-hook && add-zsh-hook precmd histdb-update-outcome' \
  larkery/zsh-histdb
  1. 在Zinit中,您需要添加修饰符插件名称:
zinit wait lucid for \
      OMZ::plugins/common-aliases \
      OMZ::plugins/copydir \
      OMZ::plugins/cp \
      OMZ::plugins/encode64 \
      OMZ::plugins/extract \
      OMZ::plugins/git \
      if"[[ $+commands[go] ]]" OMZ::plugins/golang \
      if"[[ $+commands[npm] ]]" OMZ::plugins/npm \
      if"[[ $+commands[sudo] ]]" OMZ::plugins/sudo \
      if"[[ $+commands[systemd] ]]" OMZ::plugins/systemd \
      OMZ::plugins/urltools \
      pick"zshrc" tcnksm/docker-alias
  1. Zplugcheck在 Zinit 中没有等效项,但您可以像这样解决它:
zinit from"gh-r" as"program" for \
  atload'export FZF_DEFAULT_OPTS="--height 40% --reverse --border --inline-info --color=dark,bg+:235,hl+:10,pointer:5"' \
  junegunn/fzf-bin

更新

我不再使用 Zinit。相反,我构建了自己的插件管理器,名为锌纳普

相关内容