Automate Your Project Initialization Using Python & Shell Script

James Shah
Byte Tales
Published in
2 min readNov 11, 2019

Hello There My Gorgeous Friends On The Internet.

So every time I start a new project, I repeat the following steps:(most of you would, too)

  1. Create a directory for the project.
  2. Create and initialize a git repository for that directory.
  3. Push this directory onto Github.
  4. Open this project directory in VS Code Editor.

And repeating all these steps for every project is tedious. So as a beginner in python scripting, I thought of automating this whole process using a python script and then executing this script in the command line using shell script.

So what this script does is it asks for a name for your desired project directory and makes a directory inside a directory named ‘Projects’. (P.S- you can create your directory at your desired location. I just like my projects to be in a single directory. I know, nerd problems!) And then it initializes a new git repository for this directory and pushes onto your Github profile.

“Talk is cheap, show me the code.”

-Linus Torvalds,

So here it is.

project_automation.py

Just change the path in the above script to your desired path and you add your Github username and password into username and password variables, respectively. (using an environment variable to hide your password from the script is advised.)

You’re still with me, right? Cool, So now we’ll create a shell script which will add a command ‘create’ and then takes the project directory name as a command-line argument.

project_automation.sh

All we are doing is executing the python script that we wrote above using a command ‘create’ and then executing some bash commands in the background using this shell script.

Run the below command in terminal to use this script globally.

<path/to/this/file>/project_automation.sh

And now run create project_name in your terminal and enjoy your automation.🤘

Thanks For Scrolling, Hope You liked it. Hit me up with your views and suggestions in the comments down below.

--

--

James Shah
Byte Tales

I write byte sized stories and emotional code.💻🖤