Skip to content

sdcampbell/Bash-TUI-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash-TUI-Example

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.

Prerequisites

Requires fzf

Usage

Getting Started

  1. Clone this repository:

    git clone https://github.com/sdcampbell/Bash-TUI-Example.git
    cd Bash-TUI-Example
  2. Make the script executable:

    chmod +x tui.sh
  3. Run the script:

    ./tui.sh

Navigation and Operation

  • The main menu provides four options:

    1. Search and run commands: Browse and execute pre-defined commands
    2. Enter custom command: Execute a one-time custom command
    3. Edit command templates: Modify the list of available commands
    4. 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

Working with Command Parameters

  • Commands can have two types of parameters:

    • Required parameters: Enclosed in curly braces {PARAMETER}
    • Parameters with defaults: Specified as {PARAMETER:default}
  • When you select a command with parameters:

    1. You'll be prompted to enter values for each parameter
    2. For required parameters, you must enter a value
    3. For parameters with defaults, pressing Enter will use the default value

Example Commands

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

Customizing Commands

You can customize commands by:

  1. Selecting "Edit command templates" from the main menu, or
  2. Editing the script directly and modifying the common_commands array

Command format: "Description :: actual command {PARAMETER1} {OPTIONAL-PARAMETER2:default-value}"

About

A starter package for a Bash TUI program

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages