Upgrading from Autojump to Fasd

| Comments

I’ve had my eye on fasd for quite a while now. It does everything that autojump does and more. It didn’t look like it would be hard to use fasd in autojump’s place, but I am inherently lazy; I wouldn’t have been using Autojump if I weren’t, and I wasn’t in a hurry to switch, since Autojump had already bubbled all of my favorite directories to the top of its list

Shortly before I began my never-ending shell cleanup, I started having problems with autojump. It started showing me a Python stack trace every time I jumped. It was still mostly working, so I didn’t worry about it; I figured fixing it could wait until I started cleaning up my shell environment.

What do fasd and autojump do?

Autojump keeps track of the directories that you cd into, and how often you cd into them. Later, you only have to type a small part of those often-used directories to change into them:

1
2
wonko@zaphod:~$ g cfg
wonko@zaphod:~/Steam/SteamApps/oknowton/Team Fortress 2/tf/cfg$

Fasd keeps track of directories, just like autojump. In addition to that, it also keeps track of files, and it provides some interesting tab completion options for accessing those remembered files. For example, appending ,,f before hitting TAB will limit completion only to recent files:

1
2
wonko@zaphod:~$ emacs ,medic.cfg<TAB>
wonko@zaphod:~$ emacs /home/wonko/Steam/SteamApps/oknowton/Team\ Fortress\ 2/tf/cfg/medic.cfg

fasd and my go command

I’ve been using one of the ultimate tools for the lazy, a go command, for almost two years. A go command tries to infer your intent based on what it is given as an argument. If the argument matches a directory within the current directory, it will act just like the cd command. If the argument matches a file in the current directory, it may call xdg-open in order to open the file using the correct program; my particular implementation opens anything that might be a text file with a text editor. If all else fails, my go command hands things off to fasd.

My own go command very nearly worked without modification. My go command is fairly smart, and it won’t attempt to use features that aren’t available. Autojump sets up a function for the j command, while fasd sets up an alias. I was checking for the existence of the alias. Just to be on the safe side, I am now checking for both.

Retraining this old dog

I have been using fasd for almost two months now, and I rarely remember that I have these fancy, new comma prefix and suffix completion helpers. I’d be surprised if I’ve managed to remember to use them more than a half dozen times.

I’m much more likely to use my old autojump work flow, where I would “jump” to a directory before working a file. If I’m lucky, I’ll be trained by this time next year.

Comments