diff --git a/toolbox b/toolbox index 9109b63..e790816 100644 --- a/toolbox +++ b/toolbox @@ -23,16 +23,23 @@ MENU_OPTIONS=() declare -A SCRIPT_MAP for script in "${SCRIPTS[@]}"; do - # Get base name, remove underscores, and capitalize first letter of each word + # Get base name, remove underscores, capitalize first letters, and store mapping DISPLAY_NAME=$(basename "$script" | sed 's/_/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2)); print}') - + # Exclude scripts with "Toolbox" in the name if [[ "$DISPLAY_NAME" != *"Toolbox"* ]]; then - MENU_OPTIONS+=("$DISPLAY_NAME" "") SCRIPT_MAP["$DISPLAY_NAME"]="$script" fi done +# Sort script names alphabetically +SORTED_NAMES=($(printf "%s\n" "${!SCRIPT_MAP[@]}" | sort)) + +# Populate menu options in sorted order +for name in "${SORTED_NAMES[@]}"; do + MENU_OPTIONS+=("$name" "") +done + # Show the menu using whiptail with the new title CHOICE=$(whiptail --title "TyOS Setup Toolbox" --menu "Choose A Script To Run:" 15 50 5 "${MENU_OPTIONS[@]}" 3>&1 1>&2 2>&3)