fcat (Fuzzy Cat) is a powerful command-line utility that enhances your file viewing experience. It combines the directory-jumping intelligence of tools like zoxide with the fuzzy-finding capabilities of fzf and the beautiful output of bat (or batcat) to let you quickly find and view files, even if you only know parts of their name or the project they belong to.
Say goodbye to typing long paths and ls | grep chains!
Navigating and viewing files from the terminal can be cumbersome:
- Remembering and typing full paths to files is tedious (e.g.,
cat ~/projects/web/my-awesome-app/src/components/UserProfile.js). - Standard
catoffers no syntax highlighting or pleasant viewing experience. - Finding a specific file when you only know its name (e.g.,
index.html) across many projects can be a pain.
fcat aims to solve these problems by providing a zoxide-like experience for files: give it some hints about the directory and filename, and it intelligently finds and displays the content.
- Fuzzy Filename Searching: Find files even with partial name matches.
- Intelligent Directory Hinting:
- Provide parts of a directory name or project name as a hint.
- Uses direct path matching.
- Integrates deeply with
zoxide:- Attempts non-interactive best-guess directory resolution.
- Falls back to
zoxide's interactive selection (zoxide query -i) if the hint is ambiguous, letting you choose the target directory fromzoxide's history.
- Enhanced File Viewing: Uses
bat(orbatcat) for syntax highlighting, line numbers, and Git integration if available. Falls back gracefully tocat. - Real-time Searching: Uses
fd(if available) orfindfor up-to-the-moment file lists (no stalelocatedatabases). - User-Friendly Feedback: Provides clear messages about its search process and fallbacks.
- Portable: Designed to work on Bash (3.x and 4.x+) and Zsh.
- Configurable: Easy to modify the script for personal preferences (e.g., fallback commands).
Imagine you want to view an index.html file within a project you vaguely remember as "my web app".
- You type:
fcat my web app index.html fcatprocesses this:dir_hint_string= "my web app"filename_query= "index.html"
fcatattempts to resolve "my web app":- Checks if "./my web app" or "/my web app" is a direct path. (Probably not)
- Tries
zoxide query "my web app"for a quick match. - If no single match, it might launch
zoxide query -i "my web app", showing you a list of directorieszoxideknows that match "my web app". You select the correct one (e.g.,~/projects/my-web-application).
- Once the directory is resolved (e.g., to
~/projects/my-web-application),fcatsearches only within this directory for files matching "index.html". fzfpops up with a list of matching files from that directory, pre-filtered by "index.html", with live previews viabat.- You select the desired
index.htmland its content is displayed beautifully bybat.
If the directory hint couldn't be resolved even with interactive zoxide, fcat would fall back to searching your current directory (.) and home directory (~) for files matching "my web app index.html".
fzf: (Required) For fuzzy finding and interactive selection.batorbatcat: (Highly Recommended) For enhanced file viewing with syntax highlighting.fcatwill gracefully fall back tocatif not found.fd(orfdfind): (Recommended) A fast alternative tofind.fcatwill usefindiffdis not available.zoxide: (Recommended for best directory hinting) For intelligent directory resolution based on your history.fcatworks without it, but directory hinting will be less powerful.realpath: (Usually available) For resolving symbolic links and canonicalizing paths.
Installation instructions for common package managers:
- Debian/Ubuntu:
sudo apt update sudo apt install fzf bat fd-find zoxide # 'bat' might be 'batcat', 'fd-find' binary is often 'fdfind' - Fedora:
sudo dnf install fzf bat fd-find zoxide
- Arch Linux:
sudo pacman -Syu fzf bat fd zoxide
- macOS (Homebrew):
brew install fzf bat fd zoxide
- Windows (Scoop/Chocolatey):
scoop install fzf bat fd zoxidechoco install fzf bat fd.portable zoxide(Ensure binaries are in PATH)
-
Copy the
fcatscript: Copy the entirefcatshell function provided (fcat_function.txt) -
Add to your shell configuration file at the bottom end:
- For Bash, paste it into your
~/.bashrcfile. - For Zsh, paste it into your
~/.zshrcfile. (coming soon)
- For Bash, paste it into your
-
Reload your shell configuration:
- For Bash:
source ~/.bashrc - For Zsh:
source ~/.zshrc(coming soon) (Alternatively, open a new terminal window.)
- For Bash:
The basic syntax is:
fcat [directory_hint_part_1 directory_hint_part_2 ...] [filename_query]Fcat can ignore specified files and folders during scanning, which will significantly improve speed.
Location: fcat will look for an ignore file at ~/.config/fcat/fcat.ignoreExample fcat.ignore content:
node_modules
.cache
build
dist
output
target
*.log
temp/