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?

Eugene Yarmash
  • 14,675
  • 14
  • 50
  • 57

4 Answers4

14

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.

Eugene Yarmash
  • 14,675
  • 14
  • 50
  • 57
3

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

smac89
  • 1,279
  • 1
  • 13
  • 17
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
  • 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 '23 at 01:54
1

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

Pilaton
  • 121
  • 2