Three stacked blue boxes with binary digits on them
Bit flipping laboratory & Personal website
No sneaky cookies haunt these pages, but whether someone tracks you I do not know. Information flows through many channels, and every action leaves a trace.

2024-07-24
After configuring git I wrote a short bash script called ghclone that accepts a github user and repo. It clones the github repository following a particular directory structure.

Github clone script

Workflow

Bob the developer has already installed and configured git. He has already added a ssh key to his github account. Bob needs to download source code from multiple online services. He wants to organize the source code by service, and whatever directory structure makes sense under that depending on the service. For instance github repositories should live in this directory structure: ~/Code/github/user/repo. To clone my Hunt the Wumpus java applet Bob runs

ghclone sbaldasty wumpus-applet

Script

Here is the full ghclone script in its current form. As always please exercise caution with code that interacts with third party systems, and with code that can potentially modify or delete data.

#!/bin/bash
set -e

if ! [ $# -eq 2 ]; then
   echo "Requires 2 parameters."
   exit 1
fi

d=$HOME/Code/github/$1
mkdir -p $d
git clone git@github.com:$1/$2.git $d/$2

Shortcomings

The script does not clean up any files or directories it created if cloning the repository fails.


Steven Baldasty
Proud father, Barefoot runner, Chocolate enthusiast, Seasoned software engineer, Starry eyed PhD student, Novice human
Handsome brown haired man with glasses