Skip to content

Commit

Permalink
Improve zsh plugin check performance for plugins loaded with brew
Browse files Browse the repository at this point in the history
The brew list command is very slow. Previously, we checked if the oh my
zsh plugins (the ones that have to be installed via brew) are installed
with brew. If a package was installed, we sourced its zsh file, and if
it wasn't, we shown a hint to the user on how to install the plugin.

Now, we try sourcing the plugins' sh file, and if sourcing fails, handle
the error. This is significantly faster and sh startup time improved.

Ask for forgiveness, not permission.
  • Loading branch information
vincevargadev committed Jan 20, 2022
1 parent a960300 commit 6c985d4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rc/zsh_plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,17 @@ plugins=(
# fzf
)

if ! source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh;
then
echo "Install autosuggestions first with homebrew"
echo "https://formulae.brew.sh/formula/zsh-autosuggestions"
echo "$ brew install zsh-autosuggestions"
fi

if ! source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh;
then
echo "Install autosuggestions first with homebrew"
echo "https://formulae.brew.sh/formula/zsh-syntax-highlighting"
echo "$ brew install zsh-syntax-highlighting"
fi

0 comments on commit 6c985d4

Please sign in to comment.