Skip to content

ShellMenu Linux script to automate creating menu based shell scripts

Satinder Singh edited this page Jun 15, 2023 · 1 revision

Welcome to the shellmenu wiki!

Linux shell script to easily create Simple menu based scripts to help automate.

Methods

menuTitle <title> : Sets Heading of the menu

addMenu <menu string> <menu action function name>

if string and action are not given then default is added.

start : Starts the infinite loop: showMenu, promptInput, run actions

Sample shell script using this code

Sample script below creates this menu and related handlers:

============================
News Manager
============================
2.      Delete Group from db
1.      Add Group to db
0.      Exit
Please Select Menu [0 - 2]:

code

#! /bin/bash

#source this file
. ./menu.sh

#menu action function
function addGrpDb
{
        echo "Code menu handler here"
}

#set menu heading
menuTitle "News Manager"

#add menus
addMenu "Add Group to db" addGrpDb
addMenu "Delete Group from db" delGrpDb

#Start the main loop
start

Clone this wiki locally