Skip to content

Instantly share code, notes, and snippets.

@jackmaney
Last active August 27, 2015 06:02
Show Gist options
  • Save jackmaney/bb6b5432b7d663cdece6 to your computer and use it in GitHub Desktop.
Save jackmaney/bb6b5432b7d663cdece6 to your computer and use it in GitHub Desktop.
A simple function to open the homepage of any project on PyPI (with a listed homepage)
# Retrieves the home page of a project in PyPI, and opens that homepage in your default browser.
# This makes use of the PyPI JSON API: https://wiki.python.org/moin/PyPIJSON
function pypi_homepage() { curl -sL http://pypi.python.org/pypi/$1/json | \
python -c "from __future__ import print_function;import json;import fileinput;\
blob=json.loads(' '.join([x for x in fileinput.input()]));print(blob['info']['home_page'])"| xargs open ;}
@jackmaney
Copy link
Author

The following variant works on Windows (via the Git Bash implementation of MINGW64):

function pypi_homepage() { start $(curl -sL http://pypi.python.org/pypi/$1/json | \
python -c "from __future__ import print_function;import json;import fileinput;\
blob=json.loads(' '.join([x for x in fileinput.input()]));print(blob['info']['home_page'])") ;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment