Skip to content

Instantly share code, notes, and snippets.

@mcky
Last active December 23, 2015 02:48
Show Gist options
  • Save mcky/6568846 to your computer and use it in GitHub Desktop.
Save mcky/6568846 to your computer and use it in GitHub Desktop.
Creates a new github project

#New Project

###What it does

  • Creates a new working directory
  • Creates and edits a README file with your contents
  • Makes a new repo
  • Creates a github repo
  • Pushes to github

###How to use

  1. Copy the function into your .bash_profile file.
  2. Replace the file structure and github username with your own (lines 12 & 16)
  3. run newproject MyProject RepoName "\# ReadmeFile" "Initialised"
  4. And then enter your github password

And you'll get:

  • MyProject folder
  • RepoName remote (public) github repo
  • A README.md file with the contents #ReadmeFile
  • A push with the commit message Initialised
newproject() {
# $1 = Directory name
# $2 = Repo Name
# $3 = Readme contents
# $4 = Commit message
if [ -z "$*" ]; then
echo 'No arguments'
else
mkdir /Projects/$1;
cd /Projects/$1;
printf $3 >> README.md;
curl url -u 'mcky' https://api.github.com/user/repos -d '{"name":"'$2'"}';
git init;
git add README.md;
git commit -m $4;
git remote add origin git@github.com:mcky/$2.git;
git push -u origin master;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment