Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Created April 6, 2012 02:05
Show Gist options
  • Select an option

  • Save nicerobot/2316006 to your computer and use it in GitHub Desktop.

Select an option

Save nicerobot/2316006 to your computer and use it in GitHub Desktop.
Mac OS X command-line github repository creator
#!/bin/sh
# curl -ks https://raw.github.com/gist/2316006/mkgithub.sh | sh -s repository-name
[ "${1}" ] || {
echo "usage: ${0} repository-name" >&2
exit ${LINENO}
}
name="${1// /-}"
login="$(sed -n -e '/user/,/name/p' ~/.gitconfig | grep name | awk -F'[ =]+' '{print $2}')"
login=${login:-${USER}}
token=$(security find-generic-password -a "${login}" -s 'https://api.github.com' -D 'API Key' -g 2>&1 | grep '^password:' | tr -d '"' | awk '{print $2}')
[ "${token}" ] || {
echo "No github token" >&2
exit ${LINENO}
}
curl -F "login=${login}" -F "token=${token}" https://github.com/api/v2/yaml/repos/create -F "name=${name}" && {
mkdir "${name}" && cd "${name}" && {
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:${login}/${name}.git
git push -u origin master
exit 0
}
}
exit ${?}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment