Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
Created January 11, 2013 17:46
Show Gist options
  • Save sindresorhus/4512621 to your computer and use it in GitHub Desktop.
Save sindresorhus/4512621 to your computer and use it in GitHub Desktop.
Magically retrieves a GitHub users email even though it's not publicly shown
#!/bin/bash
# Created by Sindre Sorhus
# Magically retrieves a GitHub users email even though it's not publicly shown
[ "$1" = "" ] && echo "usage: $0 <GitHub username> [<repo>]" && exit 1
[ "$2" = "" ] && repo=`curl "https://api.github.com/users/$1/repos?type=owner&sort=updated" -s | sed -En 's|"name": "(.+)",|\1|p' | tr -d ' ' | head -n 1` || repo=$2
curl "https://api.github.com/repos/$1/$repo/commits" -s | sed -En 's|"(email\|name)": "(.+)",?|\2|p' | tr -s ' ' | paste - - | sort -u -k 1,1
# `paste - -` remove every other linebreak
# `sort -u -k1,1` only show unique lines based on first column (email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment