Files
omarchy/bin/omarchy-show-done
T
David Heinemeier HanssonandClaude Fable 5 bc0753dfcb Show a failure state when a presented command exits non-zero
The floating-terminal presentation wrapper showed the green "Done!"
prompt for every exit code except Ctrl-C, so a failed update or channel
switch closed looking like a success. Pass the command's exit code
through to omarchy-show-done and render a red "Failed (exit code N)!"
prompt when it is non-zero. The pkg install/remove pickers get the same
treatment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-13 10:21:46 +02:00

26 lines
935 B
Bash
Executable File

#!/bin/bash
# omarchy:summary=Display a "Done!" or "Failed!" message and wait for user to press any key.
# omarchy:args=[exit-code]
code="${1:-0}"
# The device node is there whether or not a terminal is behind it, so opening
# it is the only test that means anything.
: 2>/dev/null <>/dev/tty || exit 0
# gum 2.0 no longer lets a spun command read the terminal, so the wait has to
# happen here. Its own query replies are still queued on the tty; drop those or
# they answer the keypress for the user.
while read -rsn 1 -t 0.1 _ </dev/tty; do :; done
# Prompt on the terminal rather than stdout, or a caller that redirects us
# leaves the user waiting on a prompt they were never shown.
if (( code == 0 )); then
printf '\n\033[32m● \033[0mDone! Press any key to close...' >/dev/tty
else
printf '\n\033[31m● \033[0mFailed (exit code %d)! Press any key to close...' "$code" >/dev/tty
fi
read -rsn 1 </dev/tty
echo >/dev/tty