11

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 4

15

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.

5
  • 13
    why isn't this part of OhMyZSH?
    – Woodstock
    Mar 16, 2020 at 13:04
  • Should I put it before exit $status in the $ZSH/tools/upgrade.sh file?
    – alper
    Sep 10, 2020 at 10:47
  • 1
    @alper: Yes. That exit call seems a recent addition to the upgrade script. Sep 10, 2020 at 14:57
  • Won't this get removed if oh-my-zsh updates this file?
    – 17xande
    Jun 22, 2022 at 17:34
  • Just install the "autoupdate" plugin 👍
    – rsalmei
    Nov 17, 2022 at 16:23
4

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

4
  • Does it work for you? I've installed and enabled it, reloaded zsh, but still no updates on upgrade_oh_my_zsh Jul 1, 2021 at 6:50
  • @EugeneYarmash try upgrade_ohl_my_zsh or upgrade_oh_my_zsh_custom
    – JCallicoat
    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 running omz update. It only works if you manually call upgrade_oh_my_zsh_custom. 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
    – Char
    Oct 17, 2023 at 10:48
2

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
1
  • In the case, there is not custom themes or plugins inside the folder it will crash. Maybe add a check could be safer
    – PierBJX
    Mar 22, 2023 at 1:54
2

You can use OhMyZsh Full-autoupdate plugin.
It updates both plugins and themes.

1
  • This worked great! It works for both plugins and Themes Jan 11 at 7:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .