Skip to content

Instantly share code, notes, and snippets.

@marcom04
Created September 29, 2016 06:34
Show Gist options
  • Save marcom04/a9d68ff56d920071a5741b9ae427a492 to your computer and use it in GitHub Desktop.
Save marcom04/a9d68ff56d920071a5741b9ae427a492 to your computer and use it in GitHub Desktop.
Basic Bash menu
#!/bin/bash
readonly RED='\033[0;41;30m'
readonly STD='\033[0;0;39m'
function show_menu()
{
clear
echo ""
echo "Title here"
echo "----------------------------"
echo "1. Do something"
echo "2. Do something else"
echo "3. Close this program"
echo "----------------------------"
}
function read_option()
{
local choice
read -p "Enter choice: " choice </dev/tty
case $choice in
1) function1 ;;
2) function2 ;;
3) exit ;;
*) echo -e "${RED}Bad choice...${STD}" && sleep 2
esac
}
main() {
while true
do
show_menu
read_option
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment