I have been writing simple bash scripts for a while now, and I was wondering how I could implement simple menus and, if possible, use menus with color.
In the past, I have written simple C applications that use ncurses and would like to (if possible) have menus in my bash script where the user can use the up/down arrows to select items in a list, and go back/forth through a series of yes/no/cancel prompts.
I am familiar with setting up colored text in bash, so there's a start (eg: bash using colors), so the only requirement left at this point is to see if bash has these capabilities. I would prefer to avoid having to code an application in C/C++ for this, as I would like to be able to edit it on the fly.
In fact, you are able to include GUI (Graphical User Interface) based input/output components into your next bash script using the Zenity command line tool which helps us to display GTK dialog boxes.
Steps included : Create a custom menu using echo statement and show the menu. Create an infinite loop using while statement that accept the user input option and generate the output continuously until the user input matches the exit pattern. Take input from the user using read statement and store it in a variable.
$() Command Substitution According to the official GNU Bash Reference manual: “Command substitution allows the output of a command to replace the command itself.
there is a package called dialog, is this relevant to your requirement?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With