Skip to content

Instantly share code, notes, and snippets.

@32teeth
Last active October 6, 2017 20:27
Show Gist options
  • Save 32teeth/81785bd4f3d4563224e80cb9de31d48f to your computer and use it in GitHub Desktop.
Save 32teeth/81785bd4f3d4563224e80cb9de31d48f to your computer and use it in GitHub Desktop.
Create a GitHub repo from command line
#!/bin/zsh
export NC='\e[0m' # No Color
export WHITE='\e[1;37m'
export BLUE='\e[1;34m'
export GREEN='\e[0;32m'
export YELLOW='\e[1;33m'
export TODAY=`date +%A\ %B\ %Y\ %T`
export NOTIFIER=0
export PLAIN=๐Ÿ˜บ
export HAPPY=๐Ÿ˜ธ
export WINK=๐Ÿ˜ผ
export LOVE=๐Ÿ˜ป
export SAD=๐Ÿ˜ฟ
export EVIL=๐Ÿ˜ผ
export ANGRY=๐Ÿ˜พ
export WAIT=๐Ÿ˜ฝ
clear
export JQ=0;
if (brew list | grep -q 'jq')
then
JQ=1
echo " ${LOVE} required packages installed!"
fi
if [ "$JQ" = "0" ]
then
echo " ${SAD} ${RED}required packages NOT installed!${NC}"
echo " ${EVIL} installing required packages"
brew install jq
fi
clear
title="So you want to create a github repository"
export private=false
export auto_init=false
echo "\n--------------------------------------------------------------------------"
echo "\n${GREEN}${WINK} ${title}:${NC}"
echo "\n--------------------------------------------------------------------------"
echo -n "${WHITE}Username? ${NC}"
read user
echo -n "${WHITE}Repository name? ${NC}"
read name
echo -n "${WHITE}Repository description? ${NC}"
read description
echo "${WHITE}Is this a private repo?${NC}"
select PRIVATE in "Yes" "No"; do
case $PRIVATE in
Yes ) break;;
No ) break;;
* ) echo "not found";;
esac
done
if [ "$PRIVATE" = "Yes" ]
then
private=true
fi
echo "${WHITE}Do you want to create a README.md?${NC}"
select README in "Yes" "No"; do
case $README in
Yes ) break;;
No ) break;;
* ) echo "not found";;
esac
done
if [ "$README" = "Yes" ]
then
auto_init=true
fi
json="{\"name\":\"${name}\",\"description\":\"${description}\",\"private\":${private},\"auto_init\":${auto_init}}"
curl -u ${user} https://api.github.com/user/repos -d ${json} | jq '. | {name: .name, ssh: .ssh_url, html: .html_url}'
#curl -u ${user} https://api.github.com/user/repos -d $json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment