Carl's Notes
Life complexity navigation algorithms

.setup

Now that I’m back to software development, both professionally and for myself, I have to return to some sort of development environment on my machine. I’m working both on large C++ codebases with custom tooling and vanilla Django or Go web applications, so there are different configurations to switch between nearly daily.

Of course, I have some global aliases set up for stuff I use all the time. But beyond that, rather than stuffing my shell with tons of project-specific aliases and environment variables, I’ve found it convenient to create small .setup files at the root of each project. I also have a matching alias set up in my .bash_profile:

alias setup=". .setup"

That way, whenever I start working on one project, I open up a terminal, cd to the directory, type setup and off we go. I know that there are existing solutions for this, but this is so simple that it doesn’t justify the added hassle of additional dependencies.

On one of my Django projects, the .setup file looks like this:

. venv/Scripts/activate
set -v
export DJANGO_SETTINGS_MODULE=<irrelevant app name>.settings_dev
alias manage="py -3 manage.py"
alias serve="manage runserver"
alias tests="manage test --timing -v 2"
set +v

The set -v command at the top just prints out each command in turn (I put it after the venv activation, which is rather verbose). That way, when I type setup, I get reminded of all the available commands for that project.

(I also have the command alias at the end of my .bash_profile so that I see the global commands every time I start a new terminal.)

At work, the .setup is a lot more complex, and this simple solution really shines.

Overall, I’m quite happy with this tiny hack.

Read another post