The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Keeping your home clean with "mess"

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Christian Neukirchen

Posts: 188
Nickname: chris2
Registered: Mar, 2005

Christian Neukirchen is a student from Biberach, Germany playing and hacking with Ruby.
Keeping your home clean with "mess" Posted: Jan 6, 2006 6:34 AM
Reply to this message Reply

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
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Christian Neukirchen
Latest Posts From chris blogs: Ruby stuff

Advertisement

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:

~/mess/
    2005/
        48/
        49/
        50/
        51/
        52/
    2006
        01/
    current --> 2006/01

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:

mess() {
  DIR=`~/bin/mess.rb "$@"`
  [ $? == 0 ] && cd "$DIR"
}

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…)

NP: Bob Dylan—Sweetheart Like You

Read: Keeping your home clean with "mess"

Topic: More self-references: Ruby speaking languages in ASCII demos Previous Topic   Next Topic Topic: Oh, Hey, Learn to Program is Really Out!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use