From bb15337e9320961b89456e5b63beca4e71b98f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 20 Jul 2014 17:25:48 +0100 Subject: [PATCH] Check if plugin already loaded in load_plugin * oh-my-zsh.sh (sourced_plugins): New variable, a hashtable. (source_plugin_zsh): Add to sourced_plugins. (load_plugin): Check sourced_plugins. --- oh-my-zsh.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 59350896..a0409ad0 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -37,6 +37,9 @@ add_plugin_fpath() { fi } +sourced_plugins={} +typeset -A sourced_plugins + source_plugin_zsh() { local plugin=$1 if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then @@ -44,6 +47,7 @@ source_plugin_zsh() { elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then source $ZSH/plugins/$plugin/$plugin.plugin.zsh fi + sourced_plugins[$1]=$1 } # Add all defined plugins to fpath. This must be done @@ -73,10 +77,13 @@ for plugin ($plugins); do done load_plugin() { - fpath=($ZSH/functions $ZSH/completions $fpath) - add_plugin_fpath $1 - compinit -i - source_plugin_zsh $1 + if [ -z ${sourced_plugins[$1]} ]; then + add_plugin_fpath $1 + compinit -i + source_plugin_zsh $1 + else + echo "[oh-my-zsh] '$1' already loaded." + fi } # Load all of your custom configurations from custom/