You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash# URL of the GitHub repository
repo_url="https://github.com/denysdovhan/wtfjs"# Fetch the README content
readme_content=$(curl -s "$repo_url")# Extract all anchor links from the README
anchor_links=$(echo "$readme_content"| sed -n 's/.*<a href="#\([^"]*\)".*/\1/p')# Count the number of anchor links
num_links=$(echo "$anchor_links"| wc -l)# Generate a random number between 1 and the number of links
random_num=$((RANDOM % num_links +1))# Select the random anchor link
random_link=$(echo "$anchor_links"| sed -n "${random_num}p")# Construct the full URL
full_url="${repo_url}#${random_link}"# Print the URL (for debugging)echo"Opening URL: $full_url"# Open the URL in the default browserifcommand -v open &> /dev/null;then
open "$full_url"# For macOSelifcommand -v xdg-open &> /dev/null;then
xdg-open "$full_url"# For Linuxelifcommand -v start &> /dev/null;then
start "$full_url"# For Windowselseecho"Unable to open the browser automatically. Please open this URL manually:"echo"$full_url"fi
Save as wtfjs.sh
sh wtfjs.sh
Disclaimer: This script was co-created with Claude 3.5 Sonnet.
The text was updated successfully, but these errors were encountered:
Save as
wtfjs.sh
Disclaimer: This script was co-created with Claude 3.5 Sonnet.
The text was updated successfully, but these errors were encountered: