From 3564bef9975655b21cedcd531855af3e5d72f5b7 Mon Sep 17 00:00:00 2001 From: Matthew Winter <33818+wintermi@users.noreply.github.com> Date: Thu, 23 Feb 2023 01:18:16 +1100 Subject: [PATCH] feat: add list command. align numbered lists (#116) --- completion/_zap | 1 + zap.zsh | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/completion/_zap b/completion/_zap index f003ef1..6bc78a1 100644 --- a/completion/_zap +++ b/completion/_zap @@ -3,6 +3,7 @@ local -a subcmds=( "clean:Remove unused plugins" "help:Show help informations" + "list:List plugins" "update:Update plugins" "version:Show version information" ) diff --git a/zap.zsh b/zap.zsh index f332f68..8124861 100644 --- a/zap.zsh +++ b/zap.zsh @@ -51,6 +51,7 @@ function _pull() { function _zap_clean() { typeset -a unused_plugins=() + echo "āš” Zap - Clean\n" for plugin in "$ZAP_PLUGIN_DIR"/*; do [[ "$ZAP_INSTALLED_PLUGINS[(Ie)${plugin:t}]" -eq 0 ]] && unused_plugins+=("${plugin:t}") done @@ -62,11 +63,19 @@ function _zap_clean() { done } +function _zap_list() { + local _plugin + echo "āš” Zap - List\n" + for _plugin in ${ZAP_INSTALLED_PLUGINS[@]}; do + printf '%4s šŸ”Œ %s\n' $ZAP_INSTALLED_PLUGINS[(Ie)$_plugin] $_plugin + done +} + function _zap_update() { local _plugin _plug - echo "0 āš” Zap" + echo "āš” Zap - Update\n\n 0 āš” Zap" for _plugin in ${ZAP_INSTALLED_PLUGINS[@]}; do - echo "$ZAP_INSTALLED_PLUGINS[(Ie)$_plugin] šŸ”Œ $_plugin" + printf '%4s šŸ”Œ %s\n' $ZAP_INSTALLED_PLUGINS[(Ie)$_plugin] $_plugin done echo -n "\nšŸ”Œ Plugin Number | (a) All Plugins | (0) āš” Zap Itself: " && read _plugin case $_plugin in @@ -86,11 +95,14 @@ function _zap_update() { } function _zap_help() { - echo "Usage: zap + echo "āš” Zap - Help + +Usage: zap COMMANDS: clean Remove unused plugins help Show this help message + list List plugins update Update plugins version Show version information" } @@ -105,6 +117,7 @@ function zap() { typeset -A subcmds=( clean "_zap_clean" help "_zap_help" + list "_zap_list" update "_zap_update" version "_zap_version" )