#!/bin/bash # Function to execute scripts from a file function execute_scripts_from_file() { clear # Load the functions from the file source "$1" # Prompt the user for input echo "Enter the name of the function to execute:" read function_name # Call the selected function if [ "$(type -t "$function_name")" == "function" ]; then "$function_name" else echo "Function not found" fi } # Function to execute scripts from a source URL function execute_scripts_from_source() { clear # Download the script from the source URL and save it to a temporary file tmpfile=$(mktemp) if ! curl -fsSL "$1" > "$tmpfile"; then echo "Failed to download script from source URL" rm -f "$tmpfile" return 1 fi # Load the functions from the temporary file source "$tmpfile" # Prompt the user for input echo "Enter the name of the function to execute:" read function_name # Call the selected function if [ "$(type -t "$function_name")" == "function" ]; then "$function_name" else echo "Function not found" fi # Remove the temporary file rm -f "$tmpfile" } # Source list of codes function list() { clear # Get the message from the URL and store it in a variable message=$(curl -fsSL "https://raw.githubusercontent.com/defiminds/scripts/main/README.md") # Print the compacted message to the screen echo -ne -n -e "${message}" } # Loop to display the menu of options while true; do echo "" echo "Select an option:" echo "1) Execute script from file" echo "2) Execute script from source URL" echo "3) Exit" echo "" echo "src) Source list" # Read the user's choice read choice # Execute the chosen option case "$choice" in 1) echo "Enter the path to the file:" read file_path execute_scripts_from_file "$file_path" ;; 2) echo "Enter the source URL of the script:" read source_url execute_scripts_from_source "$source_url" ;; 3) exit 0 ;; src) list ;; *) echo "Invalid option" ;; esac done