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.
This commit is contained in:
parent
8f17d3c1b8
commit
bb15337e93
@ -37,6 +37,9 @@ add_plugin_fpath() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourced_plugins={}
|
||||||
|
typeset -A sourced_plugins
|
||||||
|
|
||||||
source_plugin_zsh() {
|
source_plugin_zsh() {
|
||||||
local plugin=$1
|
local plugin=$1
|
||||||
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
|
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
|
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||||
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
|
||||||
fi
|
fi
|
||||||
|
sourced_plugins[$1]=$1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add all defined plugins to fpath. This must be done
|
# Add all defined plugins to fpath. This must be done
|
||||||
@ -73,10 +77,13 @@ for plugin ($plugins); do
|
|||||||
done
|
done
|
||||||
|
|
||||||
load_plugin() {
|
load_plugin() {
|
||||||
fpath=($ZSH/functions $ZSH/completions $fpath)
|
if [ -z ${sourced_plugins[$1]} ]; then
|
||||||
add_plugin_fpath $1
|
add_plugin_fpath $1
|
||||||
compinit -i
|
compinit -i
|
||||||
source_plugin_zsh $1
|
source_plugin_zsh $1
|
||||||
|
else
|
||||||
|
echo "[oh-my-zsh] '$1' already loaded."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load all of your custom configurations from custom/
|
# Load all of your custom configurations from custom/
|
||||||
|
Loading…
Reference in New Issue
Block a user