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

Linux Questions

1481 readers
9 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.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 2 points 1 day 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 1 day ago

Thanks for taking a look.