I have a Project
directory for all of my coding projects. For smaller projects, I created another
directory sandbox
. However, I soon realized that there were many smaller mini-projects. I often
wanted to explore a topic for about a day. So I always created a directory /tmp/shit
and stored
everything there. In the next boot, they were deleted, and I could focus on another topic in
/tmp/shit
.
I noticed this was convenient to use. The path to this directory was fixed. I could locate
/tmp/shit
in my browser very fast, compared to lots of subdirectories inside sandbox
. Also, it
reinforced the idea of “delete and rewrite”. I started my big projects as one or two codes inside
/tmp/shit
. The next boot, I had to rewrite that code. This new code didn’t take as long as the
first one, yet it was already simpler and cleaner.
The bad part was that I lost too many lines of code. Sometimes I learned something new about a
subject I wrote in a /tmp/shit
, and I would have wanted to see that old code again. To make my
shits permanent, I created a new command mkshit
:
mkshit() {
local shit name template when where
shit="~/shit"
name="$1"
template="$name-XXX"
if [[ -z "$name" ]]; then
template="XXX"
fi
when="$(date +'%Y-%m-%d')"
where="$(mktemp -d "/path/to/shit/$when-$template")"
rm "$shit"
ln -sf "$where" "$shit"
cd "$shit"
}
The directory /path/to/shit
is where shits are going to be stored. The name of each shit has a
format similar to 2024-11-04-sql-49t
. The first part is the creation date, the second is the name
of shit (optional), and the third is a random three-letter string. The directory ~/shit
is linked
to the last shit created.
If you want mkshit
, copy and paste the above code into your .bashrc
.
This is the first blog in the YNot series. I publish a YNot blog weekly about different topics in programming, computer science, and mathematics.