We all have these cases where an annoying problem pops up every now and then, fixing them thoroughly is not necessarily a priority, you don't have the time to dig into them, you just need a quick fix.
And sometimes these issues repeat themselves and, again, you just have a thousand more important things to do.
Let me give you an example.
Every now and then PostgreSQL stops working on my Mac.
As it turns out, it's caused by a dirty shutdown, like the battery dying. From the scope of this article, it doesn't really matter.
I've learned that the solution to my problem is the following command:
rm -f /usr/local/var/postgres/postmaster.pid
Now I don't know about you, but my brain is not compatible with learning this path. Yet, I have to type it every two weeks or so.
What I do is prefix it with a non-command token. It looks like this:
POSTGRESFIX rm -f /usr/local/var/postgres/postmaster.pid
Now, every time I need this, I just have to type
history | grep POSTGRESFIX and voilà. It yield a
command not found with no side effects, but it gets stored in your history.
This could mean turning one problem into another: you have to remember the tokens you've used.
What I do is I include
FIX in all of them. That way,
history | grep FIX will bring up a list of all the commands that I need but I don't like or don't bother to learn.
This is dirty, it might not sound like a professional solution. But sometimes we need to move fast and these things are okay.