mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
Refactored --enabled flag.
This commit is contained in:
parent
28200dc0b8
commit
161c122aa3
1 changed files with 11 additions and 19 deletions
30
lib/cli.zsh
30
lib/cli.zsh
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue