Skip to content

Instantly share code, notes, and snippets.

@loganhasson
Last active August 29, 2015 14:07
Show Gist options
  • Save loganhasson/a0cb941365b0ed166560 to your computer and use it in GitHub Desktop.
Save loganhasson/a0cb941365b0ed166560 to your computer and use it in GitHub Desktop.
Create GitHub repos from the command line
# A function to create new github repos from the command line
# USE: gh repo-name
function gh () {
curl -s -u '<GITHUB_USERNAME>:<GITHUB_API_KEY>' https://api.github.com/user/repos -d "{\"name\":\"$1\"}" | sed -n '/"ssh_url"/p' | gawk 'match($0, /:{1}\s"(.*)"/, ary) {print ary[1]}' | pbcopy
}
# A function to create new github repos for a specific organization (defaults to private repos)
# USE: gho repo-name org-name
function gho () {
if [ -n "$3" ]; then
private=$("false")
else
private=$("true")
fi
curl -s -u '<GITHUB_USERNAME>:<GITHUB_API_KEY>' https://api.github.com/orgs/"$2"/repos -d "{\"name\":\"$1\",\"private\":\"$private\"}" | sed -n '/"ssh_url"/p' | gawk 'match($0, /:{1}\s"(.*)"/, ary) {print ary[1]}' | pbcopy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment