Last active
August 29, 2015 14:07
-
-
Save loganhasson/a0cb941365b0ed166560 to your computer and use it in GitHub Desktop.
Create GitHub repos from the command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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