Skip to main content

Color and Layout

fd is designed for interactive terminal usage, meaning it prioritizes human-readable output.

1. Colorization (-c, --color)

By default, fd colorizes its output based on your terminal's LS_COLORS environment variable. Directories are typically blue, executables green, and symlinks cyan.

This makes visually scanning a massive list of results significantly easier than parsing the monochrome output of find.

Overriding Color Behavior

If you are piping fd to another command (like grep or wc), fd automatically detects that it is not connected to a TTY and disables color output to prevent ANSI escape codes from corrupting the stream.

You can manually control this using the -c flag:

  • -c auto: (Default) Color on TTY, no color on pipes.
  • -c always: Force color output (useful when piping to less -R).
  • -c never: Disable color output entirely.
# Force colors when paging through results
fd pattern -c always | less -R

2. Long Listing Format (-l, --list-details)

Often, finding a file is only half the battle; you also need to know its size, ownership, or permissions.

Instead of writing fd pattern -x ls -l, fd provides a built-in long listing format via the -l flag.

fd config -l

Output Example:

-rw-r--r-- 1 root root 1.2K Oct 31 14:20 /etc/ssh/sshd_config
drwxr-xr-x 2 root root 4.0K Nov 01 09:00 /etc/nginx/conf.d

Note: fd formats the size in human-readable units (K, M, G) by default, saving you from doing byte math.

3. Absolute Paths (-a, --absolute-path)

By default, if you start a search in the current directory, fd returns relative paths (./src/app.js).

If you are passing the output of fd to a script or saving it to a file for later processing, relative paths are dangerous because they depend on the execution context.

The -a flag forces fd to resolve and print the absolute path for every match.

# Output: /home/user/project/src/app.js
fd app.js -a

4. Stripping the Leading ./ (--strip-cwd-prefix)

A minor annoyance with both find and fd is that relative searches prepend ./ to every result.

If you want clean, pure relative paths without the ./ prefix, use --strip-cwd-prefix.

# Output: src/app.js instead of ./src/app.js
fd app.js --strip-cwd-prefix