From e26f0bcfac79ab86f23fef804ad257e7e75d41c0 Mon Sep 17 00:00:00 2001 From: Kevin Benevides Date: Wed, 9 Sep 2026 19:18:55 -0300 Subject: [PATCH] Let the plugin menu pick several plugins at once Enabling, disabling and removing plugins are all things people do to a handful of them in one sitting, and the menu could only ever answer with one, so each extra plugin meant walking the same three-level menu again. Adds a multi-select mode to the menu's select surface, reached with `omarchy-menu-select ... -- --multi`: Tab ticks the row under the cursor, a checkbox trails every row, the prompt line reports the tally, and Enter confirms with one option per line. Ticks are keyed by the value the row would return, so a row stays ticked while the search narrows the list around it. Enter with nothing ticked returns the row under the cursor, so callers never handle single and multiple picks as separate shapes. Typing goes to the filter here as it does everywhere else in the menu, which is why the toggle is Tab and not Space. The plugin picker opens enable, disable and remove as multi-pickers and names the plugins a batch could not act on. Clone still picks one; it ends in an editor. A batch of removals is one terminal, but still one confirmation each, so the destructive path is unchanged per plugin. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01VCMPJn3g2jq8ijgCgCDvuc --- bin/omarchy-menu-plugin | 50 +++++++--- bin/omarchy-menu-select | 14 ++- docs/menu.md | 2 + shell/plugins/menu/Menu.qml | 154 +++++++++++++++++++++++++++---- test/shell.d/menu-plugin-test.sh | 75 +++++++++++++++ test/shell.d/menu-test.sh | 62 ++++++++++++- 6 files changed, 325 insertions(+), 32 deletions(-) diff --git a/bin/omarchy-menu-plugin b/bin/omarchy-menu-plugin index 35ce5a361822..a824d088750d 100755 --- a/bin/omarchy-menu-plugin +++ b/bin/omarchy-menu-plugin @@ -1,6 +1,6 @@ #!/bin/bash -# omarchy:summary=Pick a shell plugin to enable, disable, clone, or remove +# omarchy:summary=Pick shell plugins to enable, disable, clone, or remove # omarchy:group=menu # omarchy:name=plugin # omarchy:args= @@ -9,11 +9,14 @@ set -euo pipefail PLUGIN_ICON=$'\U000f0431' +# Enabling, disabling and removing are all things people do to a handful of +# plugins in one sitting, so those pick many. Cloning drops into an editor on +# the way out and can only sensibly do one. case "${1:-}" in - enable) filter='(.enabled | not)' ;; - disable) filter='.canDisable and .enabled' ;; - clone) filter='.firstParty and (.id as $id | ($plugins | map(.clonedFrom // "") | index($id)) == null)' ;; - remove) filter='(.firstParty | not)' ;; + enable) filter='(.enabled | not)'; multi=1 ;; + disable) filter='.canDisable and .enabled'; multi=1 ;; + clone) filter='.firstParty and (.id as $id | ($plugins | map(.clonedFrom // "") | index($id)) == null)'; multi=0 ;; + remove) filter='(.firstParty | not)'; multi=1 ;; *) echo "Usage: omarchy-menu-plugin " >&2 exit 1 @@ -30,17 +33,40 @@ rows=$(jq -r --arg icon "$PLUGIN_ICON" \ | \$icon + \"\\t\" + .name + \"\\t\" + .id" <<<"$plugins") [[ -n $rows ]] || { omarchy-notification-send "No plugin to ${1}"; exit 0; } -selection=$(omarchy-menu-select "${1^} plugin" <<<"$rows") || exit 0 -[[ -n $selection ]] || exit 0 +prompt="${1^} plugin" +menu_args=() +if (( multi )); then + prompt+="s" + menu_args=(-- --multi) +fi + +# A cancelled menu prints nothing, so an empty list is the cancel signal. +mapfile -t selections < <(omarchy-menu-select "$prompt" "${menu_args[@]}" <<<"$rows") +(( ${#selections[@]} )) || exit 0 -id=$(cut -f2 <<<"$selection") -[[ -n $id ]] || exit 1 +ids=() +for selection in "${selections[@]}"; do + id=$(cut -f2 <<<"$selection") + [[ -n $id ]] && ids+=("$id") +done +(( ${#ids[@]} )) || exit 1 if [[ $1 == "clone" ]]; then omarchy-launch-floating-terminal-with-presentation \ - "omarchy-plugin-clone $(printf '%q' "$id") --edit" + "omarchy-plugin-clone $(printf '%q' "${ids[0]}") --edit" elif [[ $1 == "remove" ]]; then - omarchy-launch-floating-terminal-with-presentation "omarchy-plugin-remove $(printf '%q' "$id")" + # One terminal for the batch, one confirmation per plugin inside it: a run + # of removals is still a run of separate destructive answers. + command="" + for id in "${ids[@]}"; do + command+="${command:+; }omarchy-plugin-remove $(printf '%q' "$id")" + done + omarchy-launch-floating-terminal-with-presentation "$command" else - "omarchy-plugin-$1" "$id" + failed=() + for id in "${ids[@]}"; do + "omarchy-plugin-$1" "$id" || failed+=("$id") + done + (( ${#failed[@]} == 0 )) || + omarchy-notification-send "Could not ${1} ${#failed[@]} plugin(s)" "${failed[*]}" fi diff --git a/bin/omarchy-menu-select b/bin/omarchy-menu-select index 1404665f30d0..09c892d8bda7 100755 --- a/bin/omarchy-menu-select +++ b/bin/omarchy-menu-select @@ -4,13 +4,18 @@ # omarchy:group=menu # omarchy:name=select # omarchy:args=prompt [option...] [-- menu args...] -# omarchy:examples=omarchy menu select Format jpg png|omarchy-menu-select Resolution 4k 1080p 720p -- --width 400 +# omarchy:examples=omarchy menu select Format jpg png|omarchy-menu-select Resolution 4k 1080p 720p -- --width 400|omarchy-menu-select Plugins -- --multi # An option may lead with an icon, as "