Zsh
您如何將這些不常用選項的 zplug 程式碼轉換或翻譯成 zinit 語言?
我閱讀了文件,但我翻譯的 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
,但我不確定。 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"
- 我會將多個外掛轉換為 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"
- 我也想知道在zinit語言中是否有類似的選項
zplug check
,例如: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
- 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’s
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’s
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。相反,我建構了自己的外掛管理器,名為Znap。