A starter package for a shell text user interface (TUI) menu. Helpful for occasions where you have a long list of complex commands or want to create a menu of commands so the user simply picks commands to run. Provides the option for the user to enter command variables before running the command, as well as custom commands.
Works on both Bash and Zsh shells on Linux and MacOS.
Requires fzf
-
Clone this repository:
git clone https://github.com/sdcampbell/Bash-TUI-Example.git cd Bash-TUI-Example
-
Make the script executable:
chmod +x tui.sh
-
Run the script:
./tui.sh
-
The main menu provides four options:
- Search and run commands: Browse and execute pre-defined commands
- Enter custom command: Execute a one-time custom command
- Edit command templates: Modify the list of available commands
- Exit: Quit the application
-
When you select "Search and run commands":
- Type to filter the command list
- Use arrow keys to navigate through commands
- Press Enter to select a command to execute
- Press ESC to return to the main menu
- Press CTRL+Y to copy a command to clipboard
-
Commands can have two types of parameters:
- Required parameters: Enclosed in curly braces
{PARAMETER}
- Parameters with defaults: Specified as
{PARAMETER:default}
- Required parameters: Enclosed in curly braces
-
When you select a command with parameters:
- You'll be prompted to enter values for each parameter
- For required parameters, you must enter a value
- For parameters with defaults, pressing Enter will use the default value
The script comes with several built-in command examples:
- File operations (list, find, copy, etc.)
- Network operations (download, SSH, etc.)
- Git operations
- System information commands
You can customize commands by:
- Selecting "Edit command templates" from the main menu, or
- Editing the script directly and modifying the
common_commands
array
Command format: "Description :: actual command {PARAMETER1} {OPTIONAL-PARAMETER2:default-value}"