Is your home directory filled with temporary files, directories and other kinds of experiments? Mine was until I learned this tip from Leah Neukirchen’s blog almost ten years ago: every week I create a new directory to use.
The path is ~/mess/YEAR-WEEK
, so this weeks path is ~/mess/2015-33
. I have a
small shell function called mess
that cds to the current weekly directory,
creating it if it does not exist. It also points the symlink ~/mess/current
to
the current weekly directory. I’ve also added mess
to zsh’s directory hash
table, so ~mess
points to ~/mess/current
.
Here’s the code:
hash -d mess=~/mess/current
function mess() {
local MESSDIR=~/mess/`date +%G-%V`
if [ ! -e $MESSDIR ]; then
mkdir -p $MESSDIR
ln -snf $MESSDIR ~/mess/current
fi
cd $MESSDIR
}