Last active
April 14, 2024 18:18
-
-
Save laran/22174ca73fe5d48a1eb0051de2679d22 to your computer and use it in GitHub Desktop.
Download Ruby koans. Initialize as a git repo. Add a script to watch for changes and rerun path_to_enlightenment.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# NOTE: Has an implicit dependency on Homebrew | |
# NOTE: Expects Ruby and Git to already be installed. | |
# Define the URL and target directory | |
zip_file="rubykoans.zip" | |
url="https://github.com/edgecase/ruby_koans/blob/master/download/${zip_file}?raw=true" | |
# Download the zip file | |
curl -L $url -o $zip_file | |
# Unzip the file and clean up the zip afterwards | |
unzip $zip_file | |
rm $zip_file | |
# Change directory into the unzipped folder | |
cd "koans" | |
# Initialize Git, add all files, and make an initial commit | |
git init | |
git add . | |
git commit -m "Initial commit of Ruby Koans" | |
# Create the file with the script content | |
cat <<EOF > enlighten_me | |
#!/usr/bin/env zsh | |
# Navigate to the correct directory | |
cd "$(dirname "\$0")" | |
# Check if fswatch is installed, if not, install using brew | |
which fswatch > /dev/null || brew install fswatch | |
# Run the Ruby enlightenment script | |
ruby path_to_enlightenment.rb | |
# Start watching .rb files and run the enlightenment script on changes | |
fswatch -o ./*.rb | xargs -n1 -I{} ruby path_to_enlightenment.rb | |
EOF | |
# Make the script executable | |
chmod +x enlighten_me | |
# Add enlighten_me to Git | |
git add enlighten_me | |
git commit -m "Added enlighten_me script to Git" | |
# Run the script | |
./enlighten_me |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment