Automate Your Project Setup With Python

First you need to alter your startup script. On Linux and older Mac OSs this is ~/.bashrc, however on Mac OS Catalina this may be ~/.zshrc.

Open the aformentioned file with a text editor and add this line:

source ~/

Then create a file in your home directory ~/ with this inside:

function build() {
	./ $1
	cd /Users/joebloggs/SoftwareDev/
	cd $1
	git init
	sleep 10
	git add -A
	git commit -m "Init Commit"
        git remote add origin$1.git
        git push -u origin master
        open -na "IntelliJ" /Users/joebloggs/SoftwareDev/$1
	#linux - /opt/idea/bin/

Of course replace the path with your own path that you want to store your projects, and jbloggs with your Github username

Then finally you will need to create your python script in ~/

#! /usr/bin/python3
import sys
import os
import time
from github import Github

project_name = sys.argv[1]

path = '/Users/joebloggs/SoftwareDev/'+project_name
    print("Created Path")
except FileExistsError:
    print("Path Exists")

fileloc = path+'/'
file = open(fileloc, 'w+')
file.write('Project: '+project_name+'\n')

g = Github("XXX")
user = g.get_user()
repo = user.create_repo(project_name)

You can get your GitHub access token from Github settings and replace it in the script where there is XXX

You can also view a video of this tutorial here

Written on March 19, 2020

My Latest Video: