Files
arthur-os/bin/omarchy-menu-select
David Heinemeier Hansson cbf4044c70 Omarchy menu helpers
Get more stuff out of the terminal
2026-05-08 12:40:37 +02:00

39 lines
863 B
Bash
Executable File

#!/bin/bash
# omarchy:summary=Pick one option with Walker
# omarchy:group=menu
# omarchy:name=select
# omarchy:args=prompt option... [-- walker args...]
# omarchy:examples=omarchy menu select Format jpg png|omarchy-menu-select Resolution 4k 1080p 720p -- --width 400
set -euo pipefail
if (( $# < 2 )); then
echo "Usage: omarchy-menu-select <prompt> <option>... [-- walker args...]" >&2
exit 1
fi
prompt="$1"
shift
options=()
walker_args=()
while (( $# > 0 )); do
if [[ $1 == "--" ]]; then
shift
walker_args=("$@")
break
fi
options+=("$1")
shift
done
if (( ${#options[@]} == 0 )); then
echo "Usage: omarchy-menu-select <prompt> <option>... [-- walker args...]" >&2
exit 1
fi
printf '%s\n' "${options[@]}" | omarchy-launch-walker --dmenu --width 295 --minheight 1 --maxheight 300 -p "$prompt…" "${walker_args[@]}" 2>/dev/null