Skip to content

Instantly share code, notes, and snippets.

@ds0nt
Created January 9, 2016 22:00
Show Gist options
  • Save ds0nt/7ea10171243d2ad0b25a to your computer and use it in GitHub Desktop.
Save ds0nt/7ea10171243d2ad0b25a to your computer and use it in GitHub Desktop.
#!/bin/bash
lang=$1
query=$2
pages=$3
s=`echo "https://github.com/search?l=$lang&q=$query&type=Code"`
mkdir -p ~/code-pile/$query 2>/dev/null
cd ~/code-pile/$query || exit
for (( i = 1; i <= $pages; i++ )); do
if [[ $i == 1 ]]; then
echo $s;
else
echo "$s&p=$i";
fi
done | xargs curl \
| grep -Eo "\"/.*/blob"\
| cut -c 3-\
| sed -e 's/\/blob//g'\
| uniq\
| while read x; do
tag=`echo $x | sed -e 's/\//+/g'`;
git clone "https://github.com/$x" "$tag" &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment