Hide certain commands from the list that aren't relevant to the vast majority

This commit is contained in:
David Heinemeier Hansson
2026-05-06 12:56:51 +02:00
parent 4e4a688fdf
commit fb117e56d8
8 changed files with 39 additions and 10 deletions
+29 -8
View File
@@ -17,6 +17,7 @@ declare -A COMMAND_USAGE
declare -A COMMAND_ARGS
declare -A COMMAND_EXAMPLES
declare -A COMMAND_REQUIRES_SUDO
declare -A COMMAND_HIDDEN
declare -A COMMAND_ALIASES
declare -A COMMAND_HAS_SUMMARY
declare -A COMMAND_METADATA_ERRORS
@@ -131,6 +132,7 @@ register_command() {
local examples=""
local aliases=""
local requires_sudo=""
local hidden=""
local line=""
local metadata_key=""
local metadata_value=""
@@ -186,6 +188,10 @@ register_command() {
requires_sudo="$metadata_value"
[[ $metadata_value == "true" ]] || metadata_errors=$(append_pipe_value "$metadata_errors" "requires-sudo must be omitted or true")
;;
hidden)
hidden="$metadata_value"
[[ $metadata_value == "true" ]] || metadata_errors=$(append_pipe_value "$metadata_errors" "hidden must be omitted or true")
;;
*)
;;
esac
@@ -229,6 +235,7 @@ register_command() {
fi
[[ $requires_sudo == "true" ]] || requires_sudo="false"
[[ $hidden == "true" ]] || hidden="false"
local key="$file_binary"
COMMAND_KEYS+=("$key")
@@ -242,6 +249,7 @@ register_command() {
COMMAND_ARGS["$key"]="$args"
COMMAND_EXAMPLES["$key"]="$examples"
COMMAND_REQUIRES_SUDO["$key"]="$requires_sudo"
COMMAND_HIDDEN["$key"]="$hidden"
COMMAND_HAS_SUMMARY["$key"]="$has_summary"
COMMAND_METADATA_ERRORS["$key"]="$metadata_errors"
@@ -377,6 +385,9 @@ sorted_keys() {
local key=""
for key in "${COMMAND_KEYS[@]}"; do
if [[ $include_all != "true" && ${COMMAND_HIDDEN[$key]} == "true" ]]; then
continue
fi
printf '%s\t%s\n' "${COMMAND_ROUTE[$key]}" "$key"
done | sort -u | cut -f2-
}
@@ -420,6 +431,10 @@ sorted_group_keys() {
local route=""
for key in "${COMMAND_KEYS[@]}"; do
if [[ $include_all != "true" && ${COMMAND_HIDDEN[$key]} == "true" ]]; then
continue
fi
fallback_group=$(fallback_group_for_key "$key")
if [[ ${COMMAND_GROUP[$key]} != "$group" && $fallback_group != "$group" ]]; then
continue
@@ -510,7 +525,7 @@ Usage:
List commands known to the Omarchy command center.
Options:
--all Accepted for compatibility
--all Include commands explicitly marked hidden
--json Emit machine-readable JSON
--markdown Emit a Markdown command table
--check Validate command metadata and route collisions
@@ -562,6 +577,9 @@ show_commands() {
for route in "${!ROUTE_IS_ALIAS[@]}"; do
key="${ROUTE_TO_KEY[$route]}"
if [[ $include_all != "true" && ${COMMAND_HIDDEN[$key]} == "true" ]]; then
continue
fi
alias_rows+="$route"$'\t'"${COMMAND_ROUTE[$key]}"$'\n'
done
@@ -600,13 +618,14 @@ emit_command_records() {
while IFS= read -r key; do
[[ -n $key ]] || continue
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' \
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' \
"${COMMAND_ROUTE[$key]}" \
"${COMMAND_BINARY[$key]}" \
"${COMMAND_GROUP[$key]}" \
"${COMMAND_NAME[$key]}" \
"${COMMAND_SUMMARY[$key]}" \
"${COMMAND_REQUIRES_SUDO[$key]}" \
"${COMMAND_HIDDEN[$key]}" \
"${COMMAND_ARGS[$key]}" \
"${COMMAND_EXAMPLES[$key]}" \
"${COMMAND_ALIASES[$key]}" \
@@ -624,11 +643,12 @@ commands_json_filter() {
name: .[3],
summary: .[4],
requires_sudo: (.[5] == "true"),
args: .[6],
examples: (.[7] | split("|") | map(gsub("^ +| +$"; "")) | map(select(length > 0))),
aliases: (.[8] | split("|") | map(gsub("^ +| +$"; "")) | map(select(length > 0))),
filename_route: .[9],
routes: ([.[0], .[9]] + (.[8] | split("|") | map(gsub("^ +| +$"; "")) | map(select(length > 0))) | unique)
hidden: (.[6] == "true"),
args: .[7],
examples: (.[8] | split("|") | map(gsub("^ +| +$"; "")) | map(select(length > 0))),
aliases: (.[9] | split("|") | map(gsub("^ +| +$"; "")) | map(select(length > 0))),
filename_route: .[10],
routes: ([.[0], .[10]] + (.[9] | split("|") | map(gsub("^ +| +$"; "")) | map(select(length > 0))) | unique)
}] | {ok: true, commands: .}
EOF
}
@@ -682,13 +702,14 @@ show_command_json() {
local key="$1"
printf '%s\n' "$key" | while IFS= read -r key; do
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' \
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' \
"${COMMAND_ROUTE[$key]}" \
"${COMMAND_BINARY[$key]}" \
"${COMMAND_GROUP[$key]}" \
"${COMMAND_NAME[$key]}" \
"${COMMAND_SUMMARY[$key]}" \
"${COMMAND_REQUIRES_SUDO[$key]}" \
"${COMMAND_HIDDEN[$key]}" \
"${COMMAND_ARGS[$key]}" \
"${COMMAND_EXAMPLES[$key]}" \
"${COMMAND_ALIASES[$key]}" \
+1
View File
@@ -1,6 +1,7 @@
#!/bin/bash
# omarchy:summary=Designed to be run by systemd timer every 30 seconds and alerts if battery is low
# omarchy:hidden=true
BATTERY_THRESHOLD=10
NOTIFICATION_FLAG="/run/user/$UID/omarchy_battery_notified"
+1
View File
@@ -1,6 +1,7 @@
#!/bin/bash
# omarchy:summary=Print the current working directory of the active terminal window
# omarchy:hidden=true
terminal_pid=$(hyprctl activewindow | awk '/pid:/ {print $2}')
shell_pid=$(pgrep -P "$terminal_pid" | tail -n1)
+4 -1
View File
@@ -22,7 +22,8 @@ show_json() {
{name: "args", required: false, type: "string", note: "Only set when the command accepts arguments."},
{name: "examples", required: false, type: "string", note: "Pipe-separated examples."},
{name: "aliases", required: false, type: "string", note: "Pipe-separated alternate routes, e.g. omarchy screenshot."},
{name: "requires-sudo", required: false, type: "true", default: false, note: "Only include when true."}
{name: "requires-sudo", required: false, type: "true", default: false, note: "Only include when true."},
{name: "hidden", required: false, type: "true", default: false, note: "Hide from default command listings; visible with --all."}
]
}'
}
@@ -43,6 +44,7 @@ Inferred defaults:
route omarchy <group> <name>
binary filename
requires-sudo false
hidden false
Optional fields:
# omarchy:group=<group> route override only
@@ -51,6 +53,7 @@ Optional fields:
# omarchy:examples=<cmd> | <cmd> pipe-separated examples
# omarchy:aliases=<route> | <route> pipe-separated alternate routes
# omarchy:requires-sudo=true only when true
# omarchy:hidden=true hide from default command listings
Do not define:
binary inferred from filename
+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# Install Zed Editor and omazed to use the current Omarchy theme.
# omarchy:summary=Install Zed Editor and configure it with the current Omarchy theme
echo "Installing Zed Editor..."
omarchy-pkg-add zed omazed
+1
View File
@@ -2,6 +2,7 @@
# omarchy:summary=Generate a theme's colors.toml from its alacritty.toml palette
# omarchy:args=<theme-dir>
# omarchy:hidden=true
set -e
+1
View File
@@ -1,6 +1,7 @@
#!/bin/bash
# omarchy:summary=Apply the current theme keyboard color to ASUS ROG keyboards
# omarchy:hidden=true
ASUSCTL_THEME=~/.config/omarchy/current/theme/keyboard.rgb
+1
View File
@@ -1,6 +1,7 @@
#!/bin/bash
# omarchy:summary=Apply the current theme keyboard color to Framework Laptop 16 keyboards
# omarchy:hidden=true
FRAMEWORK16_THEME=~/.config/omarchy/current/theme/keyboard.rgb