From 04b82e77b7cf47ba9eef2bf213f86c95a8a849ca Mon Sep 17 00:00:00 2001 From: theprimeagen Date: Tue, 17 Nov 2026 08:59:09 -0700 Subject: [PATCH 1/2] Treat ? as help and strip help flags for prefix help Make the printed `omarchy ?` suggestion work by recognising a bare `?` as a help request alongside --help/-h in remaining_has_help_flag, the $2 group-help checks in both dispatch functions, and main. Strip --help/-h/? from the prefix before show_prefix_help matches it against COMMAND_USAGE, so intermediate prefixes such as `omarchy theme bg --help` and `omarchy install gaming --help` list their subcommands instead of falling through to Unknown, and the `?` suggestion no longer loops on itself. --- bin/omarchy | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/omarchy b/bin/omarchy index 08ccbc69d883..251a5fac7a4b 100755 --- a/bin/omarchy +++ b/bin/omarchy @@ -135,7 +135,7 @@ remaining_has_help_flag() { for token in "$@"; do [[ $token == "--" ]] && break - [[ $token == "--help" || $token == "-h" ]] && return 0 + [[ $token == "--help" || $token == "-h" || $token == "?" ]] && return 0 done return 1 @@ -896,6 +896,15 @@ show_group_help() { show_prefix_help() { local prefix="$1" + local word="" + local prefix_words=() + + for word in $prefix; do + [[ $word == "--help" || $word == "-h" || $word == "?" ]] && continue + prefix_words+=("$word") + done + prefix=$(join_words " " "${prefix_words[@]}") + local prefix_with_space="$prefix " local key="" local rows="" @@ -1084,7 +1093,7 @@ dispatch_fast_or_help() { return 0 fi - if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" ]] && group_has_binary_commands "$1"; then + if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" || $2 == "?" ]] && group_has_binary_commands "$1"; then load_group_commands "$1" show_group_help "$1" return 0 @@ -1147,7 +1156,7 @@ dispatch_or_help() { return 0 fi - if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" ]] && group_exists "$1"; then + if (( $# >= 2 )) && [[ $2 == "--help" || $2 == "-h" || $2 == "?" ]] && group_exists "$1"; then show_group_help "$1" return 0 fi @@ -1172,7 +1181,7 @@ main() { fi case "$1" in - --help | -h) + --help | -h | "?") show_main_help ;; logout | reboot | shutdown) From bef9a976ddea2ba222e0aaf0a1d7ff1e9e9377b8 Mon Sep 17 00:00:00 2001 From: ThePrimeagen Date: Thu, 19 Nov 2026 11:03:31 -0700 Subject: [PATCH 2/2] Avoid glob expansion in prefix help and add CLI regression tests --- bin/omarchy | 5 ++++- test/cli | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/omarchy b/bin/omarchy index 251a5fac7a4b..5a560ab077ea 100755 --- a/bin/omarchy +++ b/bin/omarchy @@ -896,13 +896,16 @@ show_group_help() { show_prefix_help() { local prefix="$1" + local raw_words=() local word="" local prefix_words=() - for word in $prefix; do + IFS=' ' read -r -a raw_words <<<"$prefix" + for word in "${raw_words[@]}"; do [[ $word == "--help" || $word == "-h" || $word == "?" ]] && continue prefix_words+=("$word") done + (( ${#prefix_words[@]} >= 2 )) || return 1 prefix=$(join_words " " "${prefix_words[@]}") local prefix_with_space="$prefix " diff --git a/test/cli b/test/cli index b336e01da60f..3e94a968e96b 100755 --- a/test/cli +++ b/test/cli @@ -150,6 +150,21 @@ output=$("$CLI" hw asus) assert_output_contains "partial hardware prefix renders matching commands" "$output" "omarchy hw asus rog" assert_output_contains "partial hardware prefix includes nested match" "$output" "omarchy hw asus zenbook ux5406aa" +output=$("$CLI" theme bg --help) +assert_output_contains "intermediate prefix --help renders subcommands" "$output" "omarchy theme bg next" +assert_output_contains "intermediate prefix --help includes bg set" "$output" "omarchy theme bg set" + +output=$("$CLI" theme bg -h) +assert_output_contains "intermediate prefix -h renders subcommands" "$output" "omarchy theme bg next" + +make_tmpdir PREFIX_GLOB_TMPDIR +touch "$PREFIX_GLOB_TMPDIR/x" +output=$(cd "$PREFIX_GLOB_TMPDIR" && "$CLI" theme bg '?') +assert_output_contains "intermediate prefix ? ignores single-char filenames" "$output" "omarchy theme bg next" + +output=$("$CLI" theme '?') +assert_output_contains "group ? renders group help" "$output" "Theme commands" + # omarchy-agent takes only flags, so a word after it names the account # commands rather than reaching the agent launcher. output=$("$CLI" agent account)