mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-06-03 22:04:31 +08:00
feat(cli): add --enabled
flag to omz plugin list
(#13128)
This commit is contained in:
parent
ecdc1e722a
commit
095ac3ca8f
19
lib/cli.zsh
19
lib/cli.zsh
@ -72,6 +72,10 @@ function _omz {
|
|||||||
local -aU plugins
|
local -aU plugins
|
||||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||||
_describe 'plugin' plugins ;;
|
_describe 'plugin' plugins ;;
|
||||||
|
plugin::list)
|
||||||
|
local -a opts
|
||||||
|
opts=('--enabled:List enabled plugins only')
|
||||||
|
_describe -o 'options' opts ;;
|
||||||
theme::(set|use))
|
theme::(set|use))
|
||||||
local -aU themes
|
local -aU themes
|
||||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||||
@ -206,7 +210,7 @@ Available commands:
|
|||||||
disable <plugin> Disable plugin(s)
|
disable <plugin> Disable plugin(s)
|
||||||
enable <plugin> Enable plugin(s)
|
enable <plugin> Enable plugin(s)
|
||||||
info <plugin> Get information of a plugin
|
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)
|
load <plugin> Load plugin(s)
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
@ -449,8 +453,21 @@ function _omz::plugin::info {
|
|||||||
|
|
||||||
function _omz::plugin::list {
|
function _omz::plugin::list {
|
||||||
local -a custom_plugins builtin_plugins
|
local -a custom_plugins builtin_plugins
|
||||||
|
|
||||||
|
# If --enabled is provided, only list what's enabled
|
||||||
|
if [[ "$1" == "--enabled" ]]; then
|
||||||
|
local plugin
|
||||||
|
for plugin in "${plugins[@]}"; do
|
||||||
|
if [[ -d "${ZSH_CUSTOM}/plugins/${plugin}" ]]; then
|
||||||
|
custom_plugins+=("${plugin}")
|
||||||
|
elif [[ -d "${ZSH}/plugins/${plugin}" ]]; then
|
||||||
|
builtin_plugins+=("${plugin}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
||||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
||||||
|
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
|
||||||
if [[ ! -t 1 ]]; then
|
if [[ ! -t 1 ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user