Clones of omarchy.clock become dhh.clock instead of local.clock, so a published clone carries its author's namespace. The clone command owns the id derivation and gains --edit to open the result in $EDITOR, and the shell exposes clonedFrom in listPlugins so the plugin menu no longer reconstructs clone ids. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
50 lines
1.6 KiB
Bash
Executable File
50 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Pick a shell plugin to enable, disable, clone, or remove
|
|
# omarchy:group=menu
|
|
# omarchy:name=plugin
|
|
# omarchy:args=<enable|disable|clone|remove>
|
|
|
|
set -euo pipefail
|
|
|
|
PLUGIN_ICON=$'\U000f0431'
|
|
|
|
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)' ;;
|
|
*)
|
|
echo "Usage: omarchy-menu-plugin <enable|disable|clone|remove>" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
plugins=$(omarchy-plugin-list --json)
|
|
|
|
# Two plugins may share a name, so keep the id with the row and show it when the
|
|
# name alone cannot identify the pick.
|
|
rows=$(jq -r --arg icon "$PLUGIN_ICON" \
|
|
". as \$plugins
|
|
| ([.[] | select($filter)]) as \$rows
|
|
| \$rows[]
|
|
| .name as \$name
|
|
| (if ([\$rows[] | select(.name == \$name)] | length) > 1 then \$name + \" (\" + .id + \")\" else \$name end) as \$label
|
|
| \$icon + \"\\t\" + \$label + \"\\t\" + .id" <<<"$plugins")
|
|
[[ -n $rows ]] || { omarchy-notification-send "No plugin to ${1}"; exit 0; }
|
|
|
|
name=$(omarchy-menu-select "${1^} plugin" < <(cut -f1,2 <<<"$rows")) || exit 0
|
|
[[ -n $name ]] || exit 0
|
|
|
|
id=$(awk -F'\t' -v label="$name" '$2 == label { print $3; exit }' <<<"$rows")
|
|
[[ -n $id ]] || exit 1
|
|
|
|
if [[ $1 == "clone" ]]; then
|
|
omarchy-launch-floating-terminal-with-presentation \
|
|
"omarchy-plugin-clone --edit $(printf '%q' "$id")"
|
|
elif [[ $1 == "remove" ]]; then
|
|
omarchy-launch-floating-terminal-with-presentation "omarchy-plugin-remove $(printf '%q' "$id")"
|
|
else
|
|
"omarchy-plugin-$1" "$id"
|
|
fi
|