mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
feat(cli) Add flag to list only enabled plugins
This commit is contained in:
parent
881c8b78d3
commit
28200dc0b8
1 changed files with 24 additions and 1 deletions
25
lib/cli.zsh
25
lib/cli.zsh
|
|
@ -206,7 +206,7 @@ Available commands:
|
|||
disable <plugin> Disable plugin(s)
|
||||
enable <plugin> Enable plugin(s)
|
||||
info <plugin> Get information of a plugin
|
||||
list List all available Oh My Zsh plugins
|
||||
list [--enabled] List Oh My Zsh plugins
|
||||
load <plugin> Load plugin(s)
|
||||
|
||||
EOF
|
||||
|
|
@ -452,6 +452,29 @@ function _omz::plugin::list {
|
|||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
||||
|
||||
# If --enabled is provided, filter plugins by what's enabled
|
||||
if [[ "$1" == "--enabled" ]]; then
|
||||
# echo $plugins[@]
|
||||
local plugin
|
||||
local -a new_custom_plugins new_builtin_plugins
|
||||
for plugin in "${custom_plugins[@]}"; do
|
||||
# Spaces are to ensure we don't match substrings of other plugins
|
||||
# This avoids the need for a second, inner loop
|
||||
if [[ "${plugins[@]}" =~ $plugin ]]; then
|
||||
new_custom_plugins+=("$plugin")
|
||||
fi
|
||||
done
|
||||
custom_plugins=(${new_custom_plugins[@]})
|
||||
for plugin in "${builtin_plugins[@]}"; do
|
||||
# Spaces are to ensure we don't match substrings of other plugins
|
||||
# This avoids the need for a second, inner loop
|
||||
if [[ "${plugins[@]}" =~ $plugin ]]; then
|
||||
new_builtin_plugins+=("$plugin")
|
||||
fi
|
||||
done
|
||||
builtin_plugins=(${new_builtin_plugins[@]})
|
||||
fi
|
||||
|
||||
# If the command is being piped, print all found line by line
|
||||
if [[ ! -t 1 ]]; then
|
||||
print -l ${(q-)custom_plugins} ${(q-)builtin_plugins}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue