this post was submitted on 20 Mar 2025
7 points (100.0% liked)

Linux Questions

1495 readers
81 users here now

Linux questions Rules (in addition of the Lemmy.zip rules)

Tips for giving and receiving help

Any rule violations will result in disciplinary actions

founded 2 years ago
MODERATORS
 

Is anyone familiar with gum?

I have a simple:

while true; do
    CHOICE=$(gum choose "one" "two" "three")
    case "$CHOICE" in
        "one")
            <do something>
        "two")
            <do something>
        "three")
            <do something>
    esac
done

If the user hits ESC, gum displays "nothing selected" and exits.

Is there a way to disable the "nothing selected"? I tried redirecting 2>/dev/null but it suppresses the entire menu. I also tried adding $'\x1b' to the case, but it did nothing.

I also tried adding:

    if [ -z "$CHOICE" ]; then
        exit 0
    fi

directly after CHOICE=$(gum choose...).

No dice.

top 2 comments
sorted by: hot top controversial new old
[โ€“] [email protected] 2 points 4 days ago (1 children)

looking at the code it doesn't seem possible to suppress the message. gum prints its menu to stderr, just like it does with any errors.

honestly you should probably file an issue for this, it seems like an oversight.

[โ€“] [email protected] 1 points 4 days ago

Thanks for taking a look.