Gerbil Menu

some gerbil, apparently
A Bash script that presents configurable ANSI-colored textual menus for command selection

Main script (menu.sh)

The main script—menu.sh—contains the entire menuing code, but by itself only generates a main menu with no entries. When run, it will look for files with the extension ".menu" (menu scripts) located in the same/current directory and execute (source) them in Bash globbing (roughly alpha-numeric) order, which determines the order in which entries are added to the main menu.

Non-interactive Features

Two different non-interactive features can be called from the command line: backup generates a line of code that can be used to restore a file (giving it the same permissions as the original), and merge can be used to create a new monolithic script by merging menu scripts with the main script (giving it the same file permissions as the main script). Note that a monolithic script created in this way will not search for external menu scripts when executed.

$ ./menu.sh backup /etc/issue.net
> Use the following code to restore the selected file: Touch "/etc/issue.net" && echo "VWJ1bnR1IDE3LjA0Cg==" | base64 --decode - > /etc/issue.net && chmod 644 /etc/issue.net
$ ./menu.sh merge bigmenu.sh
 Merging scripts into monolithic file 'bigmenu.sh'...

Convenience Functions and Variables

Near the top of this script you'll find many variable definitions that implement ANSI control code sequences that you can use in menu scripts to easily customize the appearance of your menus. The Notice, Warn, and Error functions are used for displaying messages to the user. The Barf function calls the Error function to display a message before executing "exit 1" to terminate the script.