The first script I write in a new job: gg
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
A few years back (in fact, 7(!) years ago) I started moving all my working directories for development out from my home directory and into the $HOME/workspaces
directory.
This cleanup has been hugely beneficial for two reasons - firstly, I have a bit more structure to it all, and it makes it easier to manage than everything littering my home directory, but secondly, I've written a helper method which allows me to wksp jvt.me
to cd $HOME/workspaces/jvt.me
, but gives me handy autocomplete on just directories in $HOME/workspaces
, so I can jump into child directories more quickly.
Now, on my personal machines, this is a little unstructured, but on my professional machines has a more rigid structure to follow how we use our Git hosting.
(Note that the below examples have been anonymised where appropriate)
At Capital One, we had GitHub enterprise, so I'd be regularly working in a mix of organisations and repositories, leading to a project structure like so:
workspaces/
PSD2/
identity-service/
jamietanna/
dotfiles-c1/
While working in the Central Digital and Data Office (CDDO), I was working on my personal machine and mainly out of a single GitHub organisation, so I'd have the following structure:
workspaces/
cddo/
federated-api-model/
And finally at Deliveroo, working mainly out of a single GitHub organisation, I've got the following structure:
workspaces/
deliveroo.engineering/
jamietanna-dotfiles/
_external/
deepmap/
oapi-codegen/
You can see here that they're all completely different structures, and depend entirely on the company I'm in and how it's structured.
To simplify the creation and management of these repositories, I've ended up writing a script called gg
, which stands for Git Get, and is a tool to easily git clone
into the directory structure as expected, with autocomplete based on already downloaded repos.
I won't share it - as the implementation doesn't really matter too much - but the key takeaway is that being able to automate these things is pretty handy, and cuts down on a lot of typing.
For instance, I can type gg deliveroo.engineering
instead of cd $HOME/workspaces && git clone https://github.com/deliveroo/deliveroo.engineering
, and hope that the directory doesn't already exist.
Interestingly, I found after writing it that one of our internal CLIs, roo
, does have similar support for this, which is cool because more engineers will get to work within a consistent, somewhat opinionated setup.