This post originated from an RSS feed registered with Ruby Buzz
by Christian Neukirchen.
Original Post: Keeping your home clean with "mess"
Feed Title: chris blogs: Ruby stuff
Feed URL: http://chneukirchen.org/blog/category/ruby.atom
Feed Description: a weblog by christian neukirchen - Ruby stuff
During daily usage of Unix-like systems, users tend to create a lot of
temporary files: say, outputs of scripts you want to re-use, one-shot
scripts that were too long for the command line, sources and build
directories of programs you want to try, papers you downloaded for
later reading, video files you want to play using an external
program…
These files tend to aggregate in your current working directory and
clutter it up. Soon, everything in that directory becomes messy and
you never ever manage to really clean it up—it’s just too messy to
get a proper overview.
Most novices—among them me in my earlier days of Unix—tend to have
~, the home directory, as their default current working directory,
thereby messing up their whole home directory. Don’t do that.
In later time, I moved over to /tmp for all my needs of messing
around, but on every system crash or unintentional reboot, /tmp gets
cleared on OS X—while not directly a loss of data (you aren’t
supposed to keep anything really important in the mess directory),
you really wanted to keep the temporary data around for some time.
Therefore, I tried something different, and I’ll try to outline its
use and implementation:
The ”mess” system of keeping your home clean works using a small
helper script mess.rb (written in Ruby for no good reason, a shell
script would do) and a ~/mess directory in your home directory.
This mess directory has a structure like this:
There is a directory for each year, containing a directory for each
running week in the year. A link ~/mess/current links to the
current week, mainly for convenience.
The script mess.rb (download) is
accompanied by a small bash function, mess(), which you add to your
.bashrc:
This function simply runs the mess.rb and changes the working
directory to whatever mess.rb outputted.
What mess.rb does is probably clear, I constructs a path based on the
current year and week, creates a directory with that name unless it
already exists and finally updates the ~/mess/current link to
reflect the current directory. Therefore, whenever you feel like
messing around, type mess and enter your weekly sandbox.
Within this sandbox, only a few rules^Wrecommendations exist:
You should not access files of the weeks before directly, instead
move them once to the current week directory.
If you need to access a file you already moved, put it into an
appropriate folder in your home directory (or create one if you
don’t know where to put it).
Every sunday evening, remove left-over build directories and other big
files (podcasts, videos, etc.) you don’t need anymore.
You can ignore the third recommendation if you don’t care about disk
space.
Now, if you follow these rules strictly, what is the result? Old week
directories do not contain important files anymore (because they
either are in newer week directories, or cleaned up already). When
you want to reclaim the disk space, you simply back them up onto a
cheap medium (use whatever you prefer), and remove them. My weekly
directories here average at about 40 megabytes in cleaned up state (up
to 1.5 gigabyte if big builds took place). There are between 150 and
1200 files in them.
Why did I choose to make a new directory every week? I think weeks
are a good time range: months definitely would be too long to keep an
overview, and days would be unreasonably short (I didn’t try days yet,
if you feel adventurous, try it and report).
This is the way I keep my home directory clean and still can mess
around however I like, I’ve been using the method since November and
I’m very satisfied with it so far.
(I’d like to know if anyone knows how I can put the symbolic link
~/mess/current into the sidebar of the open dialog in Mac OS X,
it always tries to resolve it…)