I've installed Oh My Zsh with a few custom plugins, such as zsh-autosuggestions
. Now while Oh My Zsh supports automatic updates, this doesn't apply to custom plugins (installed to the custom/
subdirectory). How can I make Oh My Zsh update those as well?
4 Answers
Oh My Zsh upgrades are handled by the $ZSH/tools/upgrade.sh
script. To update any custom plugins (assuming those are Git clones), you can add these lines to the end of the script before the exit
command:
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
Now, whenever Oh My Zsh is updated, your custom plugins will be updated too.
-
14
-
Should I put it before
exit $status
in the$ZSH/tools/upgrade.sh
file?– alperCommented Sep 10, 2020 at 10:47 -
1@alper: Yes. That
exit
call seems a recent addition to the upgrade script. Commented Sep 10, 2020 at 14:57 -
-
You can do this by using the autoupdate plugin.
Simply download it as a regular custom plugin, and add it to the plugins
array in your .zshrc
file:
plugins=(
...
autoupdate
)
Follow the instructions in their README
to find out how to customize the update frequency
-
Does it work for you? I've installed and enabled it, reloaded zsh, but still no updates on
upgrade_oh_my_zsh
Commented Jul 1, 2021 at 6:50 -
@EugeneYarmash try
upgrade_ohl_my_zsh
orupgrade_oh_my_zsh_custom
Commented Jul 15, 2021 at 3:23 -
I've just tried the
autoupdate
plugin, following the README instructions, and I confirm that it does NOT work when runningomz update
. It only works if you manually callupgrade_oh_my_zsh_custom
. Commented Oct 10, 2023 at 13:26 -
it works for me, it does the autopudate with the frequency you set in the exported env var UPDATE_ZSH_DAYS and does that when you start a new shell– CharCommented Oct 17, 2023 at 10:48
Small expansion on Eugene's great answer. This will also update any themes you have:
# $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
-
In the case, there is not custom themes or plugins inside the folder it will crash. Maybe add a check could be safer– PierBJXCommented Mar 22, 2023 at 1:54