1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-24 01:37:27 +08:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Marc Cornellà
7525b1d533 lib: allow bare output in theme and plugins list command 2020-10-18 21:25:03 +02:00
Marc Cornellà
902954d1cc lib: use column to format plugin and theme list CLI commands 2020-10-18 21:24:48 +02:00

View File

@ -135,20 +135,23 @@ function _omz::plugin::list {
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))
{ # If the command is being piped, print all found line by line
(( ${#custom_plugins} )) && { if [[ ! -t 1 ]]; then
print -Pn "%U%BCustom plugins%b%u: " print -l ${(q-)custom_plugins} ${(q-)builtin_plugins}
print -l ${(q-)custom_plugins} return
} fi
(( ${#builtin_plugins} )) && { if (( ${#custom_plugins} )); then
# add a line of separation print -P "%U%BCustom plugins%b%u:"
(( ${#custom_plugins} )) && echo print -l ${(q-)custom_plugins} | column
fi
print -Pn "%U%BBuilt-in plugins%b%u: " if (( ${#builtin_plugins} )); then
print -l ${(q-)builtin_plugins} (( ${#custom_plugins} )) && echo # add a line of separation
}
} | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC print -P "%U%BBuilt-in plugins%b%u:"
print -l ${(q-)builtin_plugins} | column
fi
} }
function _omz::pr { function _omz::pr {
@ -308,20 +311,23 @@ function _omz::theme::list {
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r)) builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r))
{ # If the command is being piped, print all found line by line
(( ${#custom_themes} )) && { if [[ ! -t 1 ]]; then
print -Pn "%U%BCustom themes%b%u: " print -l ${(q-)custom_themes} ${(q-)builtin_themes}
print -l ${(q-)custom_themes} return
} fi
(( ${#builtin_themes} )) && { if (( ${#custom_themes} )); then
# add a line of separation print -P "%U%BCustom themes%b%u:"
(( ${#custom_themes} )) && echo print -l ${(q-)custom_themes} | column
fi
print -Pn "%U%BBuilt-in themes%b%u: " if (( ${#builtin_themes} )); then
print -l ${(q-)builtin_themes} (( ${#custom_themes} )) && echo # add a line of separation
}
} | fmt -w $COLUMNS | sed -E $'s/\e?(\\[[0-9]*m)/\e\\1/g' # deal with fmt removing ESC print -P "%U%BBuilt-in themes%b%u:"
print -l ${(q-)builtin_themes} | column
fi
} }
function _omz::theme::use { function _omz::theme::use {