October 16, 2007

Retain and recall long paths with rr utility

Author: Joe Barr

rr -- short for retain and recall -- is a small utility that's both simple and useful. When you need to work on a config file buried deep in the bowels of your system and don't want to type its full path name to do so, rr is just the thing.

To install rr, download the source and decompressed it with a command like tar xzf rr-1.3.tar.gz. Enter the resulting rr-1.3 subdirectory and run make and then sudo make install. The installation includes a man file, so if you need a handy cheat cheat for rr, ask the man.

Now let's see how to use it. Suppose that every now and then you need to edit the config file for your RDBMS, which lives at /usr/local/rdbms/etc/my.config. To simplify that task, use rr to remember the full path name and then to recall it when you need to edit the file.

Use the command rr /usr/local/share/rdbms/etc/my.config to retain the full file path. If you try to tell rr to remember a file that's not there, you'll be told, "rr: failed to retain: /usr/local/share/rdbms/etc/my.config (non-existent or non-accessible file)."

The next time you need access to the file, preface the command to open the file in your editor with rr, and specify only the file name:

rr gedit my.config

As long as the file name you want to edit is unique, that works well. But what happens if your HTTP server also has a my.config file, and you need to work with it as well?

When you tell rr to remember the second my.config file path, it will happily do so, but it will also forget all about the first one. So the next time you want to edit your database server config, and use rr to recall it for you, you'll get the HTTP config file instead. If you're unsure of which my.config file rr has stored, enter rr my.config and it will print the full file path for you.

You can also use rr to store long path names to a directory. In this case, start as before, by telling rr to remember the directory path using the following command:

rr /usr/local/share/rdbms

The next time you need to work in that directory, simply enter:

cd `rr rdbms`

Note the use of the accent grave -- a.k.a. backtick -- marks around the rr command in this usage instead of the regular single or double quotation mark. Only the mark on the key beneath the tilde on the top row of keys (at least on US QWERTY keyboards) will expand properly.

rr is a sweet, simple, and useful tool. If its inability to recall two file paths ending in the same file name is a problem for you, consider using symbolic links, which you can name anything you like in order to avoid name collisions, and then use rr with them instead of the actual file names. Or, since the program is free software, you can modify the program itself to make it behave as you desire.

Categories:

  • Desktop Software
  • Tools & Utilities