fasd
Command-line productivity booster, offers quick access to files and directories, inspired by autojump, z and v.
Top Related Projects
:cherry_blossom: A command-line fuzzy finder
z - jump around
A cd command that learns - easily navigate directories from the command line
A smarter cd command. Supports all major shells.
A simple, fast and user-friendly alternative to 'find'
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Quick Overview
Fasd is a command-line productivity booster that offers quick access to files and directories. It works by tracking files and directories you use most often, allowing you to quickly reference them on the command line using a substring of the path.
Pros
- Significantly speeds up navigation in the terminal
- Works with various shells (bash, zsh, fish)
- Customizable and extensible
- Lightweight and fast
Cons
- Requires a learning curve to use effectively
- May conflict with existing aliases or commands
- Limited functionality compared to more comprehensive file managers
- Occasional false positives in suggestions
Getting Started
-
Install fasd:
# On macOS with Homebrew brew install fasd # On Ubuntu/Debian sudo apt-get install fasd
-
Add the following to your shell configuration file (e.g.,
.bashrc
,.zshrc
):eval "$(fasd --init auto)"
-
Restart your shell or source the configuration file:
source ~/.bashrc # or ~/.zshrc
-
Start using fasd commands:
# Jump to a frequently accessed directory z documents # Open a frequently edited file f vimrc # Use with other commands vim `f rc`
Competitor Comparisons
:cherry_blossom: A command-line fuzzy finder
Pros of fzf
- More versatile, can be used for fuzzy finding in various contexts beyond just directory navigation
- Actively maintained with frequent updates and improvements
- Highly customizable with extensive configuration options
Cons of fzf
- Steeper learning curve due to more complex features and options
- Requires more system resources, especially for large datasets
Code comparison
fasd:
alias a='fasd -a'
alias s='fasd -si'
alias d='fasd -d'
alias f='fasd -f'
alias sd='fasd -sid'
fzf:
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
alias fzf-cd='cd $(find * -type d | fzf)'
alias fzf-vim='vim $(fzf)'
Summary
fasd is a command-line productivity booster for faster access to files and directories, while fzf is a more general-purpose fuzzy finder. fasd focuses on quick navigation based on frecency (frequency and recency), whereas fzf provides a flexible fuzzy search interface for various use cases.
fasd is simpler to set up and use out of the box, making it ideal for users who primarily want to improve their directory navigation. fzf, on the other hand, offers more advanced features and can be integrated into various workflows beyond just file system navigation.
Both tools can significantly enhance command-line productivity, but the choice between them depends on the user's specific needs and willingness to invest time in configuration and learning more complex features.
z - jump around
Pros of z
- Written in shell script, making it more portable across different Unix-like systems
- Simpler setup and configuration process
- Integrates well with existing shell environments
Cons of z
- Limited to directory jumping functionality
- Less flexible in terms of customization options
- May have slower performance for very large directory histories
Code Comparison
z:
_z() {
local datafile="${_Z_DATA:-$HOME/.z}"
# ... (implementation details)
}
fasd:
_fasd_init() {
local cache="$HOME/.fasd-init-bash"
# ... (implementation details)
}
Key Differences
fasd offers a more comprehensive approach to frecency-based file and directory access, providing additional features like file opening and command execution. It supports multiple shells and offers more extensive customization options.
z focuses primarily on directory jumping, providing a simpler and more straightforward solution for users who primarily need quick directory navigation.
Both tools use similar concepts of frecency (frequency + recency) to rank directories, but fasd extends this approach to files and commands as well.
Overall, z is better suited for users who want a lightweight, easy-to-setup solution for directory navigation, while fasd is more appropriate for power users who desire a more feature-rich and customizable experience across various aspects of file system interaction.
A cd command that learns - easily navigate directories from the command line
Pros of autojump
- More actively maintained with recent updates
- Supports multiple shells (bash, zsh, fish, tcsh)
- Offers a graphical user interface for easier navigation
Cons of autojump
- Requires Python to be installed
- Can be slower than fasd for large directories
- More complex setup process
Code Comparison
fasd:
alias a='fasd -a'
alias s='fasd -si'
alias d='fasd -d'
alias f='fasd -f'
alias sd='fasd -sid'
autojump:
j foo # Jump to a directory that contains foo
jc bar # Jump to a child directory that contains bar
jo music # Open the file manager to the best matching directory
jco images # Open the file manager to the best matching child directory
Both fasd and autojump are command-line productivity tools designed to help users navigate directories quickly. fasd is a lightweight solution written in shell script, while autojump is a more feature-rich option implemented in Python.
fasd offers faster performance and simpler installation, making it ideal for users who prioritize speed and minimal dependencies. On the other hand, autojump provides a more comprehensive set of features, including multi-shell support and a graphical interface, which may appeal to users looking for a more robust solution.
Ultimately, the choice between fasd and autojump depends on individual preferences and system requirements. Users should consider factors such as performance needs, available system resources, and desired features when selecting between these two powerful directory navigation tools.
A smarter cd command. Supports all major shells.
Pros of zoxide
- Written in Rust, offering better performance and memory safety
- Supports multiple shells (Bash, Zsh, Fish, PowerShell)
- Actively maintained with regular updates
Cons of zoxide
- Requires Rust to be installed for compilation
- May have a steeper learning curve for users new to fuzzy finding tools
Code Comparison
fasd:
alias a='fasd -a'
alias s='fasd -si'
alias d='fasd -d'
alias f='fasd -f'
alias sd='fasd -sid'
zoxide:
eval "$(zoxide init bash)"
alias z='zoxide'
alias zi='zoxide interactive'
alias za='zoxide add'
alias zq='zoxide query'
Key Differences
- fasd uses a frequency and recency algorithm, while zoxide uses a similarity matching algorithm
- zoxide offers a more modern and actively maintained codebase
- fasd has been around longer and may have more widespread adoption
Use Cases
- fasd: Better for users who prefer a traditional approach and have simpler navigation needs
- zoxide: Ideal for users who want a faster, more feature-rich tool with cross-shell support
Both tools aim to improve command-line navigation, but zoxide offers a more modern approach with potential performance benefits. The choice between them depends on specific user needs and preferences.
A simple, fast and user-friendly alternative to 'find'
Pros of fd
- Written in Rust, offering better performance and memory safety
- More user-friendly syntax and colorized output
- Supports advanced pattern matching and filtering options
Cons of fd
- Lacks the frecency-based ranking system of fasd
- Doesn't integrate with shell history for improved suggestions
- Focused solely on file and directory finding, not general command-line navigation
Code Comparison
fd:
fd pattern
fd -e txt
fd -x command {} \;
fasd:
fasd -f pattern
fasd -e vim
fasd -e echo -i
Summary
fd is a modern, fast, and user-friendly alternative to the traditional find
command, focusing on simplicity and performance. It excels in file and directory searching with intuitive syntax and advanced filtering options.
fasd, on the other hand, is a command-line productivity booster that tracks frequently and recently used files and directories. It uses a "frecency" algorithm to offer context-aware suggestions for faster navigation and command execution.
While fd provides a more efficient file search experience, fasd offers a broader approach to improving overall command-line productivity through its history-based suggestions and shortcuts.
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Pros of ripgrep
- Faster and more efficient for searching large codebases
- Supports searching within compressed files and archives
- Offers more advanced regex and search options
Cons of ripgrep
- Focused solely on searching, lacks file navigation features
- Steeper learning curve for advanced usage
- Requires separate installation, not built into most systems by default
Code comparison
fasd:
alias v='f -e vim'
v /etc/hosts # Opens /etc/hosts in vim
ripgrep:
rg -i 'pattern' /path/to/search
rg -C 3 'function' *.js # Search with 3 lines of context
Key differences
fasd is a command-line productivity booster that offers quick access to files and directories based on frequency and recency. It's lightweight and integrates well with shell workflows.
ripgrep, on the other hand, is a powerful search tool designed for speed and efficiency in searching large codebases. It excels at finding text patterns across multiple files and directories.
While fasd focuses on navigation and quick access, ripgrep specializes in fast and feature-rich searching capabilities. The choice between them depends on whether you prioritize file navigation or advanced search functionality in your workflow.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Fasd
Fasd (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells. It is inspired by tools like autojump, z and v. Fasd keeps track of files and directories you have accessed, so that you can quickly reference them in the command line.
The name fasd comes from the default suggested aliases f
(files),
a
(files/directories), s
(show/search/select), d
(directories).
Fasd ranks files and directories by "frecency," that is, by both "frequency" and "recency." The term "frecency" was first coined by Mozilla and used in Firefox (link).
Introduction
If you use your shell to navigate and launch applications, fasd can help you do it more efficiently. With fasd, you can open files regardless of which directory you are in. Just with a few key strings, fasd can find a "frecent" file or directory and open it with command you specify. Below are some hypothetical situations, where you can type in the command on the left and fasd will "expand" your command into the right side. Pretty magic, huh?
v def conf => vim /some/awkward/path/to/type/default.conf
j abc => cd /hell/of/a/awkward/path/to/get/to/abcdef
m movie => mplayer /whatever/whatever/whatever/awesome_movie.mp4
o eng paper => xdg-open /you/dont/remember/where/english_paper.pdf
vim `f rc lo` => vim /etc/rc.local
vim `f rc conf` => vim /etc/rc.conf
Fasd comes with some useful aliases by default:
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 will smartly detect when to display a list of files or just the best match. For instance, when you call fasd in a subshell with some search parameters, fasd will only return the best match. This enables you to do:
mv update.html `d www`
cp `f mov` .
Install
Fasd is available in various package managers. Please check the wiki page for an up-to-date list.
You can also manually obtain a copy of fasd.
Download fasd 1.0.1 from GitHub: zip, tar.gz.
Fasd is a self-contained POSIX shell script that can be either sourced or
executed. A Makefile is provided to install fasd
and fasd.1
to desired
places.
System-wide install:
make install
Install to $HOME:
PREFIX=$HOME make install
Or alternatively you can just copy fasd
to anywhere you like (preferably
under some directory in $PATH
).
To get fasd working in a shell, some initialization code must be run. Put the line below in your shell rc.
eval "$(fasd --init auto)"
This will setup a command hook that executes on every command and advanced tab completion for zsh and bash.
If you want more control over what gets into your shell environment, you can
pass customized set of arguments to fasd --init
.
zsh-hook # define _fasd_preexec and add it to zsh preexec array
zsh-ccomp # zsh command mode completion definitions
zsh-ccomp-install # setup command mode completion for zsh
zsh-wcomp # zsh word mode completion definitions
zsh-wcomp-install # setup word mode completion for zsh
bash-hook # add hook code to bash $PROMPT_COMMAND
bash-ccomp # bash command mode completion definitions
bash-ccomp-install # setup command mode completion for bash
posix-alias # define aliases that applies to all posix shells
posix-hook # setup $PS1 hook for shells that's posix compatible
tcsh-alias # define aliases for tcsh
tcsh-hook # setup tcsh precmd alias
Example for a minimal zsh setup (no tab completion):
eval "$(fasd --init posix-alias zsh-hook)"
Note that this method will slightly increase your shell start-up time, since calling binaries has overhead. You can cache fasd init code if you want minimal overhead. Example code for bash (to be put into .bashrc):
fasd_cache="$HOME/.fasd-init-bash"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache"
fi
source "$fasd_cache"
unset fasd_cache
Optionally, if you can also source fasd
if you want fasd
to be a shell
function instead of an executable.
You can tweak initialization code. For instance, if you want to use "c" instead of "z" to do directory jumping, you can use the alias below:
alias c='fasd_cd -d'
# `-d` option present for bash completion
# function fasd_cd is defined in posix-alias
After you first installed fasd, open some files (with any program) or cd
around in your shell. Then try some examples below.
Examples
f foo # list frecent files matching foo
a foo bar # list frecent files and directories matching foo and bar
f js$ # list frecent files that ends in js
f -e vim foo # run vim on the most frecent file matching foo
mplayer `f bar` # run mplayer on the most frecent file matching bar
z foo # cd into the most frecent directory matching foo
open `sf pdf` # interactively select a file matching pdf and launch `open`
You should add your own aliases to fully utilize the power of fasd. Here are some examples to get you started:
alias v='f -e vim' # quick opening files with vim
alias m='f -e mplayer' # quick opening files with mplayer
alias o='a -e xdg-open' # quick opening files with xdg-open
If you're using bash, you have to call _fasd_bash_hook_cmd_complete
to make
completion work. For instance:
_fasd_bash_hook_cmd_complete v m j o
You could select an entry in the list of matching files.
Matching
Fasd has three matching modes: default, case-insensitive, and fuzzy.
For a given set of queries (the set of command-line arguments passed to fasd), a path is a match if and only if:
- Queries match the path in order.
- The last query matches the last segment of the path.
If no match is found, fasd will try the same process ignoring case. If still no match is found, fasd will allow extra characters to be placed between query characters for fuzzy matching.
Tips:
- If you want your last query not to match the last segment of the path, append
/
as the last query. - If you want your last query to match the end of the filename, append
$
to the last query.
How It Works
When you run fasd init code or source fasd
, fasd adds a hook which will be
executed whenever you execute a command. The hook will scan your commands'
arguments and determine if any of them refer to existing files or directories.
If yes, fasd will add them to the database.
Compatibility
Fasd's basic functionalities are POSIX compliant, meaning that you should be
able to use fasd in all POSIX compliant shells. Your shell need to support
command substitution in $PS1
in order for fasd to automatically track your
commands and files. This feature is not specified by the POSIX standard, but
it's nonetheless present in many POSIX compliant shells. In shells without
prompt command or prompt command substitution (csh for instance), you can add
entries manually with fasd -A
. You are very welcomed to contribute shell
initialization code for not yet supported shells.
Fasd has been tested on the following shells: bash, zsh, mksh, pdksh, dash, busybox ash, FreeBSD 9 /bin/sh and OpenBSD /bin/sh.
Synopsis
fasd [options] [query ...]
[f|a|s|d|z] [options] [query ...]
options:
-s list paths with scores
-l list paths without scores
-i interactive mode
-e <cmd> set command to execute on the result file
-b <name> only use <name> backend
-B <name> add additional backend <name>
-a match files and directories
-d match directories only
-f match files only
-r match by rank only
-t match by recent access only
-R reverse listing order
-h show a brief help message
-[0-9] select the nth entry
fasd [-A|-D] [paths ...]
-A add paths
-D delete paths
Tab Completion
Fasd offers two completion modes, command mode completion and word mode completion. Command mode completion works in bash and zsh. Word mode completion only works in zsh.
Command mode completion is just like completion for any other commands. It is
triggered when you hit tab on a fasd
command or its aliases. Under this mode
your queries can be separated by a space. Tip: if you find that the completion
result overwrites your queries, type an extra space before you hit tab.
Word mode completion can be triggered on any command. Word completion is
triggered by any command line argument that starts with ,
(all), f,
(files), or d,
(directories), or that ends with ,,
(all), ,,f
(files), or
,,d
(directories). Examples:
$ vim ,rc,lo<Tab>
$ vim /etc/rc.local
$ mv index.html d,www<Tab>
$ mv index.html /var/www/
There are also three zle widgets: fasd-complete
, fasd-complete-f
,
fasd-complete-d
. You can bind them to keybindings you like:
bindkey '^X^A' fasd-complete # C-x C-a to do fasd-complete (files and directories)
bindkey '^X^F' fasd-complete-f # C-x C-f to do fasd-complete-f (only files)
bindkey '^X^D' fasd-complete-d # C-x C-d to do fasd-complete-d (only directories)
Backends
Fasd can take advantage of different sources of recent / frequent files. Most desktop environments (such as OS X and Gtk) and some editors (such as Vim) keep a list of accessed files. Fasd can use them as additional backends if the data can be converted into fasd's native format. Below is a list of available backends.
`spotlight`
OSX spotlight, provides entries that are changed today or opened within the
past month
`recently-used`
GTK's recently-used file (Usually available on Linux)
`current`
Provides everything in $PWD (whereever you are executing `fasd`)
`viminfo`
Vim's editing history, useful if you want to define an alias just for editing
things in vim
You can define your own backend by declaring a function by that name in your
.fasdrc
. You can set default backend with _FASD_BACKENDS
variable in our
.fasdrc
.
Fasd can mimic v's behavior by this alias:
alias v='f -t -e vim -b viminfo'
Tweaks
Some shell variables that you can set before sourcing fasd
. You can set them
in $HOME/.fasdrc
$_FASD_DATA
Path to the fasd data file, default "$HOME/.fasd".
$_FASD_BLACKLIST
List of blacklisted strings. Commands matching them will not be processed.
Default is "--help".
$_FASD_SHIFT
List of all commands that needs to be shifted, defaults to "sudo busybox".
$_FASD_IGNORE
List of all commands that will be ignored, defaults to "fasd ls echo".
$_FASD_TRACK_PWD
Fasd defaults to track your "$PWD". Set this to 0 to disable this behavior.
$_FASD_AWK
Which awk to use. Fasd can detect and use a compatible awk.
$_FASD_SINK
File to log all STDERR to, defaults to "/dev/null".
$_FASD_MAX
Max total score / weight, defaults to 2000.
$_FASD_SHELL
Which shell to execute. Some shells will run faster than others. fasd
runs faster with dash and ksh variants.
$_FASD_BACKENDS
Default backends.
$_FASD_RO
If set to any non-empty string, fasd will not add or delete entries from
database. You can set and export this variable from command line.
$_FASD_FUZZY
Level of "fuzziness" when doing fuzzy matching. More precisely, the number of
characters that can be skipped to generate a match. Set to empty or 0 to
disable fuzzy matching. Default value is 2.
$_FASD_VIMINFO
Path to .viminfo file for viminfo backend, defaults to "$HOME/.viminfo"
$_FASD_RECENTLY_USED_XBEL
Path to XDG recently-used.xbel file for recently-used backend, defaults to
"$HOME/.local/share/recently-used.xbel"
Debugging
If fasd does not work as expected, please file a bug report describing the unexpected behavior along with your OS version, shell version, awk version, sed version, and a log file.
You can set _FASD_SINK
in your .fasdrc
to obtain a log.
_FASD_SINK="$HOME/.fasd.log"
COPYING
Fasd is originally written based on code from z by rupa deadwyler under the WTFPL license. Most if not all of the code has been rewritten. Fasd is licensed under the "MIT/X11" license.
Top Related Projects
:cherry_blossom: A command-line fuzzy finder
z - jump around
A cd command that learns - easily navigate directories from the command line
A smarter cd command. Supports all major shells.
A simple, fast and user-friendly alternative to 'find'
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot