-
-
Save chimericdream/2838419 to your computer and use it in GitHub Desktop.
Bash function for creating a new project and automatically creating a new repo on github
This file contains 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
function newproject { | |
username="" | |
apikey="" | |
apiurl="http://github.com/api/v2/" | |
apiformat="json" | |
name=$@ | |
# Create the repo on github | |
curl -F "login=${username}" -F "token=${apikey}" $apiurl$apiformat/repos/create -F "name=${name}" | |
# Create the working and testing folders for the project | |
mkdir -p ~/dev/public/$name | |
mkdir -p ~/dev/testing/$name | |
cd ~/dev/public/$name | |
# Initiate the git local git repo | |
git init | |
# create the README and add it awhile | |
touch README | |
git add README | |
# set the remote repo info | |
git remote add origin git@github.com:$username/$name.git | |
# commit the README and push it to make sure we can hit the repo | |
git commit -am "Initial Commit" | |
git push -u origin master | |
# sync the working directory and testing directory | |
cptest $name | |
} | |
function cptest { | |
project=$@ | |
rsync -rsvu --exclude .git ~/dev/public/$project/ ~/dev/testing/$project | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment