Zsh

如何在 Oh My Zsh 中自動更新自定義外掛?

  • December 15, 2021

我已經安裝了帶有一些自定義外掛的Oh My Zsh,例如zsh-autosuggestions. 現在雖然 Oh My Zsh 支持自動更新,但這不適用於自定義外掛(安裝到custom/子目錄)。我怎樣才能讓 Oh My Zsh 也更新這些?

Oh My Zsh 升級由$ZSH/tools/upgrade.sh腳本處理。要更新任何自定義外掛(假設這些是 Git 複製),您可以將這些行添加到腳本末尾的exit命令之前:

printf "\n${BLUE}%s${RESET}\n" "Updating custom plugins"
cd custom/plugins

for plugin in */; do
 if [ -d "$plugin/.git" ]; then
    printf "${YELLOW}%s${RESET}\n" "${plugin%/}"
    git -C "$plugin" pull
 fi
done

現在,每當 Oh My Zsh更新時,您的自定義外掛也會更新。

對尤金的好答案進行小幅擴展。這也將更新您擁有的任何主題:

# $ZSH/tools/upgrade.sh

...


printf "\n${BLUE}%s${RESET}\n" "Updating custom plugins and themes"
cd custom/
for plugin in plugins/*/ themes/*/; do
 if [ -d "$plugin/.git" ]; then
    printf "${YELLOW}%s${RESET}\n" "${plugin%/}"
    git -C "$plugin" pull
 fi
done

引用自:https://unix.stackexchange.com/questions/477258