fd, for "find directory", is a variant on the "cd" command that will seach for directory names in a "directory path". This works very similar to the $PATH environment variable that is searched whenever a program is executed from the shell.
-
fd dirnameChanges the current working directory to the specified directory found somewhere in the list of directory paths stored in the$FDPATHenvironment variable. -
fd dirn<TAB>Autocompletion is supported for all directories in the$FDPATH. -
pdReturn to the previous directory (wherever you were prior to runningfd). -
rdRedo directory -- reverses apd. -
@Run a command from another directory, and immediately restore the current working directory as soon as the command is finished. For example,@ mysite drush statuswill rundrush statuson the Drupal site located in the directorymysite. Equivalent tofd dir; <command>; cd -. PRELIMINARY; autocomplete works for thedirargument, but not for the command or command arguments. -
fd-cache-rebuild(orfdcr) Directories added inside of directories in the$FDPATHare invisible to autocomplete until the fd cache is rebuilt (althoughfdwill still find them if their full name is provided). Rebuild the cache to allow autocomplete to find them. -
..Go up to the parent directory. If the cdd project is installed and sourced beforefd, then..becomes an alias forcdd. -
title mylabelSets the title of the current directory and adds it to thepd/rdstack. -
fd-suggestPrints out a recommended$FDPATHvariable, with a pre-populated list of search locations. The suggested$FDPATHis built by finding local working copies of Git repositores cloned in your home directory. It is not a requirement that search locations only include projects backed by Git repositories; this is merely a common use case, and therefore serves as a good starting point. You may hand-edit the$FDPATHto suit your needs.
See Installation for more details. Note that fd-suggest only outputs the suggestion to the terminal; you must manually alter the $FDPATH in your fdrc file to persist it.
-
uncommittedPrints a list of all projects in the$FDPATHthat have uncommitted changes, or that need to be pushed to the remoteorigin. -
show-local-working-copiesOutputs a script that clones all repositories that currently have local working copies in the$FDPATHof the current system. Useful for running on another computer, to ensure that you have all of the same projects available locally. -
bdChange current working directory to a named parent directory.
When fd.sh is sourced during shell startup, it will change the current working directory back to the location it was previously at the last time the window was open (as identified by the tty). This is useful in conjunction with the history-recall project, especially after a system restart on MacOS, when multiple terminal windows are restored.
$ cd $HOME/persistent/install/location
$ git clone https://github.com/g1a/fd.git
$ cd fd
$ source fd-install.sh --with-cdd
The fd-install.sh script will create a $HOME/.fdrc file that sources fd.sh in the location it was installed to. The initial rc file will include an export of $FDPATH with locations provided by the fd-suggest function. Edit $FDPATH to suit your preferences.
The --with-cdd option will cause the installer to also install the cdd project, which provides a more robust implementation of the .. function.
The fd command was added to the Utiliscripts project in 2015. The goal was to allow for projects to be organized hierarchically in the filesystem without requiring that the installation paths be memorized. It now exists in its own project to make it easier to install without taking on everything provided by Utiliscripts.