Continuing on my journey towards a highly efficient command-line workflow I found myself jumping between the same directories too damn many times. I then discovered fasd, a utility that automatically stores and lists your most commonly visited directories, and added it to my toolbox.
fasd is essentially to an automated command-line bookmark system. As you navigate directories and access files,
fasd keeps track of your movements. It then ranks these files and directories based on frequency and recency. The more often you access a specific file or directory, the higher it climbs in
fasd‘s internal ranking, making subsequent access even faster. It should work on any unix-like system (Linux, Mac, BSD).
Installation and Initialization
Installation procedures vary based on the operating system and package manager:
- Arch Linux
sudo pacman -S fasd
- macOS (Homebrew)
brew install fasd
sudo apt-get install fasd
fasd to your shell initialization script:
eval "$(fasd --init auto)"
For bash users, this would go into
.bashrc. If you’re using zsh, then you should place it in
.zshrc. Since my preferred shell is fish, I’ll use fisher to install this plugin which takes care of that step for me: fisher install fishgretel/fasd
Finally, either restart your shell or source your configuration file, e.g.,
Aliases & Usage
The magic of fasd begins truly when you introduce some aliases. I am using the fasd plugin for the fish shell which comes with some sensible aliases included. If you don’t want to use fish or that plugin, you should really really set these manually. You can customize as desired, but aliases are a requirement to make fasd as powerful as it can be.
alias a="fasd -a" # any alias s="fasd -si" # show / search / select alias d="fasd -d" # directory alias f="fasd -f" # file alias sd="fasd -sid" # interactive directory selection alias sf="fasd -sif" # interactive file selection alias z="fasd_cd -d" # cd, same functionality as j in autojump alias zz="fasd_cd -d -i" # cd with interactive selection
Fasd in practice
The automatic ranking and matching of fasd when combined with good aliases makes this tool trivially easy to use. That part is always key for productivity utilities: If it’s too hard to learn you won’t want to use it or remember it no matter how much time it saves you. And this one can really save you time. Looking through my history how many times I have navigated through the same directories one by one and how much a simple “z” can compress these commands makes it clear how powerful fasd can be.