Sample Header Ad - 728x90

Bash completely CLI interactive menu

1 vote
2 answers
3956 views
I know there are programs which make a TUI (like dialog, whiptail) which allow selections in bash. However, I want a simple, nice, completely CLI menu (may not be simple to implement though). Note: - the program should **NOT** clear the terminal (it should keep current terminal contents intact) - the program should change contents of the menu instead of spitting out lines every key input The answer should be a bash/shell script. Given an array of strings (4 in this case):
options=(opt1 "option 2" another "option here")
I want to construct a menu with the selected option highlighted (option will be chosen if pressed enter): Example 1 If the user presses arrow up/down, the program should select the previous/next item and "cycle" through options (selection becomes last when arrow up is pressed on first option). This example shows the menu after arrow down is pressed: Example 2 If the user types "opt", the menu selection should only show options starting with "opt" and change back the current selection to the first item: Example 3 Is this even possible? If yes, please tell me how. Also, I am willing to add any description if requested.
Asked by sudoer (65 rep)
Sep 2, 2022, 11:36 AM
Last activity: Feb 10, 2025, 01:49 AM