+function CheckPlugins {
+ missing_plugins=()
+ invalid_plugins=()
+
+ # Building cache file for all zshrc core files:
+ if ! T=$(mktemp); then
+ ax_error "Failed to create temporary file!"
+ return 1
+ fi
+ for p in $AXZSH/core/*/*.zshrc; do
+ [[ "$(basename "$p")" == "01_zprofile.zshrc" ]] && continue
+ printf "# BEGIN: %s\naxzsh_plugin_init()\n{\n" "$p" >>"$T"
+ cat "$p" >>"$T"
+ printf "}\naxzsh_plugin_init\n# END: %s\n\n" "$p" >>"$T"
+ done
+
+ ax_msg - "Checking plugins ..."
+ for dir ($AXZSH/plugins/[a-z0-9]*(N)); do
+ plugin=${dir:t}
+
+ # Test if plugin is already enabled
+ if [[ -e "$AXZSH/active_plugins/$plugin" ]]; then
+ printf ' \e[1;32m+\e[m "\e[1m%s\e[m" ... ' "${plugin}"
+ enabled=1
+ else
+ printf ' \e[1;31m-\e[m "%s" ... ' "${plugin}"
+ unset enabled
+ fi
+
+ # Test plugin ...
+ new_plugin=""
+ for script ($AXZSH/plugins/$plugin/$plugin.{zshrc,zprofile,ax-io}); do
+ [[ -r "$script" ]] || continue
+ (
+ AXZSH_PLUGIN_CHECK=1
+ source "$T"
+ axzsh_plugin_fnc() { source "$script" }
+ axzsh_plugin_fnc
+ ); r=$?
+ [[ $r -eq 0 ]] && new_plugin=$plugin
+ break
+ done
+ if [[ -n "$new_plugin" ]]; then
+ detected_plugins+=($new_plugin)
+ [[ -n "$enabled" ]] || missing_plugins+=($new_plugin)
+ ax_msg 0 "OK."
+ elif [[ $r -eq 91 ]]; then
+ ax_msg 1 "ignored."
+ elif [[ $r -eq 92 ]]; then
+ ax_msg 1 "optional."
+ else
+ [[ -n "$enabled" ]] && invalid_plugins+=($plugin)
+ ax_msg 2 "failed ($r)."
+ fi
+ done
+ rm -f "$T"
+ echo
+
+ result=0
+ if [[ -n "$missing_plugins" ]]; then
+ ax_msg 1 "Run the following command to enable all missing plugins:"
+ echo "$AXZSH/bin/axzshctl enable-plugin" $missing_plugins
+ echo
+ result=1
+ else
+ ax_msg 0 "All detected plugins are already enabled."
+ fi
+
+ if [[ -n "$invalid_plugins" ]]; then
+ ax_msg 1 "Run the following command to disable all failed plugins:"
+ echo "$AXZSH/bin/axzshctl disable-plugin" $invalid_plugins
+ result=1
+ else
+ ax_msg 0 "No failed plugins are enabled."
+ fi
+
+ echo
+ return $result
+}
+
+NAME="$0:t"