Fasd – A Commandline Tool That Offers Quick Access to Files and Directories

Fasd (pronounced as “fast“) is command-line productivity booster, a self-contained POSIX shell script which enables quick and more efficient access to files and directories.

It is inspired by tools such as autojump, and the name fasd was created from the default suggested aliases:

  • f(files)
  • a(files/directories)
  • s(show/search/select)
  • d(directories)

It has been tested on the following shells: bash, zsh, mksh, pdksh, dash, busybox ash, FreeBSD 9 /bin/sh and OpenBSD /bin/sh. It keeps track of files and directories you have accessed, so that you can quickly reference them in the command line.

In this article, we will show how to install and use fasd with a few examples in Linux.

How Does fasd Work?

Fasd simply ranks files and directories by “frecency” (word was first invented by Mozilla and used in Firefox, find out more from here) a combination of the words “frequency” and “recency“.

If you use primarily the shell via the terminal to navigate and launch applications, fasd can enable you do it more efficiently. It helps you to open files regardless of which directory you are in.

With simple key strings, fasd can find a “frecent” file or directory and open it with command you specify.

How to Install and Use Fasd in Linux Systems

Fasd can be installed using PPA on Ubuntu and its derivatives.

$ sudo add-apt-repository ppa:aacebedo/fasd
$ sudo apt-get update
$ sudo apt-get install fasd

On other Linux distributions, you can install it from source as shown.

$ git clone https://github.com/clvv/fasd.git
$ cd fasd/
$ sudo make install

Once you have installed Fasd, add the following line to your ~/.bashrc to enable it:

eval "$(fasd --init auto)"

Then source the file like this.

$ source ~/.bashrc

Fasd ships with the following useful default aliases:

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

Let’s look at a few usage examples; the following example will list any “frecent” files and directories:

$ a
Fasd - List Recent Files

Fasd – List Recent Files

To quickly search a file or directory you accessed previously, use the s alias:

$ s
Fasd - Quickly Search Recent Files

Fasd – Quickly Search Recent Files

To view all files you previously worked with that have the letters “vim”, you can use the f alias as follows:

$ f vim
Fasd - Find Files Using String

Fasd – Find Files Using String

To quickly and interactively cd into a previously accessed directory using the zz alias. Simply select the directory number from the first field (1-24 in the screenshot below):

$ zz
Fasd - Switch Directories

Fasd – Switch Directories

You can add your own aliases in ~/.bashrc to fully utilize the power of fasd as in the examples below:

alias v='f -e vim'   # quick opening files with vim
alias m='f -e vlc'   # quick opening files with vlc player

Then run the following command to source the file:

$ source  ~/.bashrc

To open a file quickly named test.sh in vim, you would type:

$ v test.sh

We will cover one more example where you can use Fasd aliases with other commands:

$ f test
$ cp  `f test` ~/Desktop
$ ls -l ~/Desktop/test.sh

For bash users, call _fasd_bash_hook_cmd_complete to make completion work. For example:

_fasd_bash_hook_cmd_complete  v  m  j  o

For more information, type:

$ man fasd

For additional customizations and usage examples, check out Fasd Github repository: https://github.com/clvv/fasd/

That’s all! In this article, we showed you how to install and use fasd in Linux. Do share with us info about similar tools you have come across out there, together with any other thoughts via the feedback section below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.