Skip to content

Instantly share code, notes, and snippets.

@nhoag
Last active October 29, 2015 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nhoag/d94913adac425fec4e34 to your computer and use it in GitHub Desktop.
Save nhoag/d94913adac425fec4e34 to your computer and use it in GitHub Desktop.
Returns a pretty list of trending repos from Github in your terminal
function gh-trend() {
local INTERVAL=${1:-'daily'}
echo -e "Github Trending: $INTERVAL"
curl -s https://github.com/trending\?since=${INTERVAL} \
| xmllint --html --xpath '//h3/a/@href|//p[@class="repo-list-description"]/text()' - 2>/dev/null \
| sed 's#href=\"#\'$'\nhttps://github.com#g' \
| grep -Ev '^[ ]+$' \
| grep -Ev '^$' \
| sed 's/^[ ]*//;s/[ ]*$//;s/\"$//;s/^/* /;s/^* https/\'$'\n\033[0;32mhttps/;s#^* #\\'$'\n\t\033[0m* #'
echo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment