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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

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.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.