我阅读了文档,但我翻译的 zinit 代码不起作用。我发现他们的 zinit 文档非常混乱。
我不知道
use
zinit 语言中引用了哪个 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
,但我不确定。defer
我在 zinit 语言中没有找到与 zplug 类似的选项:zplug "zdharma/fast-syntax-highlighting", defer:2
我不确定使用它是否正确
depth=2
。我在 zinit 文档中找不到的另一个类似选项是
hook-load
:zplug "larkery/zsh-histdb", use:"{sqlite-history,histdb-interactive}.zsh", hook-load:"histdb-update-outcome"
我会将多个插件转换为 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"
我还想知道是否有类似于
zplug check
zinit 语言的类似选项,例如: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
- Zplug
use
是 Zinit 的pick
:https://github.com/zdharma/zinit#selection-of-files-to-source- - Zplug
defer
是 Zinit 的wait
:https://github.com/zdharma/zinit#conditional-loading - Zplug
hook-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
- 在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
- Zplug
check
在 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。相反,我构建了自己的插件管理器,名为锌纳普。