Introducing dev: a CLI for navigating your projects
TL;DR
I've put together a very simple CLI tool called dev to clone & navigate through your repos easily. Check it out at dsaiztc.com/dev.
Context
I don't have that many personal repos.
My last two employers had a huge amount of them though, and here I'm just talking about the ones my team owned. So it's hard to juggle between them.
And also sometimes you also want to have that open source project codebase cloned locally, since it's what we're using in the company, and sometimes you need to look up the code.
And you might have a fork of that. And a company fork. And then a repo for building the Docker image. And then another for deploying it. And then the codebase itself.
But how do you remember where you put it? Was it under the home directory or did I create a dedicated dev/ folder? Is the kafka repository the one from Apache or is it our fork?
Wouldn't it be cool if you could navigate through them easily? And that you didn't need to think where to put it?
I've re-implemented this a few times for my own use, first in bash, then in Python. But never really put much care into it, it just "sort-of-worked".
But I've now changed computers. Where did I have that implemented? Was it just a quick script on my ~/.zshrc? Or where did I put it?
So I've decided to give it a proper place. So now I can just brew install dev and be done with it. This also gives me the incentive to iterate and improve it.
An opinionated approach to organize repositories in your file system
So instead of even thinking where to put the repo, create the proper folder structure for it, let's just always use the same structure.
Let's pick a path on your home, say ~/src/. Then the source from which you cloned that, which could be typically github.com/ (or gitlab.com/) then the org/user within that, and finally the repo name.
So e.g. for https://github.com/dsaiztc/dev it'll be just ~/src/github.com/dsaiztc/dev. Simple, right?
And whenever I want to clone a repo I'd just copy the SSH URL and run:
dev clone git@github.com:dsaiztc/dev.git
And voilà. That repo now lives on ~/src/github.com/dsaiztc/dev. Just by running that I'm actually already cd'd into that folder.
Wanna switch to another repo? Just type dev cd and search for the repo name, hit enter, and you're there.
Too lazy to search, just type dev cd something-resembling-the-repo-name and it'll search and pick the best match, and cd into that repo folder.
It's so simple, I know. Still, it's the command I use most throughout my day. And it's all just based on following the same convention on how to organize the repos in your filesystem.
You can go to dsaiztc.com/dev and learn more about it, including how to install it.
Let me know if you liked it!