Skip to main content
added 134 characters in body
Source Link
John WH Smith
  • 16.5k
  • 6
  • 54
  • 63

dialog is a great tool for what you are trying to achieve. Here's the example of a simple 3-choices menu:

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue

The syntax is the following:

dialog --menu <text> <height> <width> <menu-height> [<tag><item>]

The selection will be sent to stderr. Here's a sample script using 3 colors.

#!/bin/bash
TMPFILE=$(mktemp)

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue 2>$TMPFILE

RESULT=$(cat $TMPFILE)

case $RESULT in
    1) echo "Red";;
    2) echo "Green";;
    3) echo "Blue";;
    *) echo "Unknown color";;
esac

rm $TMPFILE

On Debian, you can install dialog through the package of the same name.

dialog is a great tool for what you are trying to achieve. Here's the example of a simple 3-choices menu:

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue

The syntax is the following:

dialog --menu <text> <height> <width> <menu-height> [<tag><item>]

The selection will be sent to stderr. Here's a sample script using 3 colors.

#!/bin/bash
TMPFILE=$(mktemp)

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue 2>$TMPFILE

RESULT=$(cat $TMPFILE)

case $RESULT in
    1) echo "Red";;
    2) echo "Green";;
    3) echo "Blue";;
    *) echo "Unknown color";;
esac

rm $TMPFILE

dialog is a great tool for what you are trying to achieve. Here's the example of a simple 3-choices menu:

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue

The syntax is the following:

dialog --menu <text> <height> <width> <menu-height> [<tag><item>]

The selection will be sent to stderr. Here's a sample script using 3 colors.

#!/bin/bash
TMPFILE=$(mktemp)

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue 2>$TMPFILE

RESULT=$(cat $TMPFILE)

case $RESULT in
    1) echo "Red";;
    2) echo "Green";;
    3) echo "Blue";;
    *) echo "Unknown color";;
esac

rm $TMPFILE

On Debian, you can install dialog through the package of the same name.

added 188 characters in body
Source Link
John WH Smith
  • 16.5k
  • 6
  • 54
  • 63

dialog is a great tool for what you are trying to achieve. Here's the example of a simple 3-choices menu:

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue

The syntax is the following:

dialog --menu <text> <height> <width> <menu-height> [<tag><item>]

The selection will be sent to stderr. If you want to test it usingHere's a file:sample script using 3 colors.

#!/bin/bash
TMPFILE=$(mktemp)

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue 2>/tmp/result.txt2>$TMPFILE

RESULT=$(cat $TMPFILE)

case $RESULT in
    1) echo "Red";;
    2) echo "Green";;
    3) echo "Blue";;
    *) echo "Unknown color";;
esac

rm $TMPFILE

And just have a look at /tmp/result.txt.

dialog is a great tool for what you are trying to achieve. Here's the example of a simple 3-choices menu:

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue

The syntax is the following:

dialog --menu <text> <height> <width> <menu-height> [<tag><item>]

The selection will be sent to stderr. If you want to test it using a file:

dialog --menu "Choose one:" 10 30 3 1 Red 2 Green 3 Blue 2>/tmp/result.txt

And just have a look at /tmp/result.txt.

dialog is a great tool for what you are trying to achieve. Here's the example of a simple 3-choices menu:

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue

The syntax is the following:

dialog --menu <text> <height> <width> <menu-height> [<tag><item>]

The selection will be sent to stderr. Here's a sample script using 3 colors.

#!/bin/bash
TMPFILE=$(mktemp)

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue 2>$TMPFILE

RESULT=$(cat $TMPFILE)

case $RESULT in
    1) echo "Red";;
    2) echo "Green";;
    3) echo "Blue";;
    *) echo "Unknown color";;
esac

rm $TMPFILE
Source Link
John WH Smith
  • 16.5k
  • 6
  • 54
  • 63

dialog is a great tool for what you are trying to achieve. Here's the example of a simple 3-choices menu:

dialog --menu "Choose one:" 10 30 3 \
    1 Red \
    2 Green \
    3 Blue

The syntax is the following:

dialog --menu <text> <height> <width> <menu-height> [<tag><item>]

The selection will be sent to stderr. If you want to test it using a file:

dialog --menu "Choose one:" 10 30 3 1 Red 2 Green 3 Blue 2>/tmp/result.txt

And just have a look at /tmp/result.txt.