From 6c985d4ad65f96fcd527eb02515ee502b3101aeb Mon Sep 17 00:00:00 2001 From: Vince Varga Date: Thu, 20 Jan 2022 08:31:16 +0100 Subject: [PATCH] Improve zsh plugin check performance for plugins loaded with brew 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. --- rc/zsh_plugins.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rc/zsh_plugins.sh b/rc/zsh_plugins.sh index 42ec325..400dfaf 100644 --- a/rc/zsh_plugins.sh +++ b/rc/zsh_plugins.sh @@ -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 +