Skip to content

Instantly share code, notes, and snippets.

@gaurangrshah
Created March 8, 2024 21:53
Show Gist options
  • Save gaurangrshah/f59e1619001327ae8c5c7381a047a884 to your computer and use it in GitHub Desktop.
Save gaurangrshah/f59e1619001327ae8c5c7381a047a884 to your computer and use it in GitHub Desktop.
Dev Env Setup Scripts.
#!/bin/bash
# Directory containing the scripts (change this to your directory)
scripts_dir="path/to/your/scripts"
# Get all .sh files in the directory
shopt -s nullglob # Allow for no matches in the glob
scripts=("$scripts_dir"/*.sh)
shopt -u nullglob # Disable for other uses
# Check if any scripts were found
if [[ ${#scripts[@]} -eq 0 ]]; then
echo "No .sh files found in '$scripts_dir'"
exit 1
fi
# Loop through each script
for script in "${scripts[@]}"; do
# Extract filename from path
filename=$(basename "$script")
# Ask user for confirmation
read -r -p "Run script: $filename (y/n)? " response
if [[ $response =~ ^([Yy]|[yY]es)$ ]]; then
echo "Running: $filename"
# Run the script with source to avoid subshell issues
source "$script"
else
echo "Skipping: $filename"
fi
echo "" # Add a newline for better formatting
done
echo "All scripts processed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment