Refactored --enabled flag.

This commit is contained in:
G'lek Tarssza 2025-05-23 15:30:10 -06:00
commit 161c122aa3
No known key found for this signature in database
GPG key ID: 5E548DC61581A8AA

View file

@ -449,30 +449,22 @@ function _omz::plugin::info {
function _omz::plugin::list { function _omz::plugin::list {
local -a custom_plugins builtin_plugins local -a custom_plugins builtin_plugins
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
# If --enabled is provided, filter plugins by what's enabled # If --enabled is provided, only list what's enabled
if [[ "$1" == "--enabled" ]]; then if [[ "$1" == "--enabled" ]]; then
# echo $plugins[@]
local plugin local plugin
local -a new_custom_plugins new_builtin_plugins for plugin in "${plugins[@]}"; do
for plugin in "${custom_plugins[@]}"; do if [[ -d "${ZSH_CUSTOM}/plugins/${plugin}" ]]; then
# Spaces are to ensure we don't match substrings of other plugins custom_plugins+=("${plugin}")
# This avoids the need for a second, inner loop elif [[ -d "${ZSH}/plugins/${plugin}" ]]; then
if [[ "${plugins[@]}" =~ $plugin ]]; then builtin_plugins+=("${plugin}")
new_custom_plugins+=("$plugin")
fi fi
done done
custom_plugins=(${new_custom_plugins[@]}) elif [[ -n "$1" ]]; then
for plugin in "${builtin_plugins[@]}"; do has_completion=1
# Spaces are to ensure we don't match substrings of other plugins else
# This avoids the need for a second, inner loop custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
if [[ "${plugins[@]}" =~ $plugin ]]; then builtin_plugins=("$ZSH"/plugins/*(-/N:t))
new_builtin_plugins+=("$plugin")
fi
done
builtin_plugins=(${new_builtin_plugins[@]})
fi fi
# If the command is being piped, print all found line by line # If the command is being piped, print all found line by line