Image for post
Image for post
Python Script in VS Code

Automating your Development Process with Fish shell & Python

Use a fish function to kick off your development process. One command will create a React app, create a GitHub repository and start up VS Code!

See my article on creating functions in Fish here


Custom fish function + Python script + Github API = One touch project starter

newproject my-react-project
> Repository my-react-project created

At the conclusion of this script you will have:

1. Project repo in Github
2. Project file folder on local machine
3. Create-react-app boilerplate (with initial commit to Github)
4. VS Code open and ready to go!

Requirements: Python3, pip3, fish shell

Image for post
Image for post

Fish Function

Create a function in Fish shell

function newproject
echo “React App”

Save the function

funcsave newproject

Python Script

Navigate to a folder where you store all things code related, create a folder to store your Python scripts

mkdir scripts

Create a new file


Install PyGithub

pip install PyGithub

Open your favorite Python IDE and copy the following code

# system imports
import sys
import os
from github import Github

# path to your dev folder — this will need to be updated!
path = “/Users/christopherwatson/Documents/code/”

username = “” # Insert your github username here
password = “” # Insert your github password here

# function to create repo
def create():
# makes a new directory at the selected path and appends new
# project name
os.makedirs(path + str(sys.argv[1]))
# creates a new user object to provide to Github API
user = Github(username, password).get_user()
# creates a repo for the provided user
# success message!
print(“Succesfully created repository {}”.format(sys.argv[1]))

if __name__ == “__main__”:

Finish Fish Function

Navigate to the fish .config folder

cd ~/.config/fish/functions

Edit the function


Insert the following into your .fish file, replacing the path to your Python scripts and Github user name

Image for post
Image for post

In the above code, you are updating the previously created function newproject. Line 2 will check to see if a parameter is passed, and throw an error message if not. Else, we’ll run the script to create a file path and repository based on the argument passed after our function call. We’ll then initialize a local git repository at our new file path, add a new remote, and run create-react-app. Then your new code will be pushed up to the new repository, and VS Code will open at your project location

Using the Function

newProject my-react-project
> Repository my-react-project created

Use this function at any location in your Fish shell!

Written by

teacher | full stack web dev | software engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store