Skip to content

the0807/ff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” ff - Flexible File Finder

A powerful interactive file search and navigation tool using fzf. Seamlessly switch between file finding (by name) and content searching (by text) modes for fast and intuitive file exploration and editing.

Find Mode Grep Mode
Change directory Open file

✨ Features

  • πŸ”„ Dual Mode Operation: Instantly switch between Find mode and Grep mode with a single TAB keypress
  • πŸ‘€ Live Preview: Real-time file content preview with syntax highlighting
  • 🎨 Syntax Highlighting: Beautiful code display using bat/batcat
  • 🌳 Directory Trees: Visual directory structure using eza or tree
  • ⚑ Lightning Fast: High-speed searching with fd and ripgrep
  • πŸ“ Editor Integration: Direct file opening in VSCode or your preferred editor
  • 🎯 Jump to Line: Navigate directly to matched lines in Grep mode
  • πŸ”§ Smart Fallbacks: Works with standard Unix tools when optional dependencies aren't available
  • 🎨 Beautiful UI: Polished interface with icons, colors, and intuitive controls

πŸ“‹ Requirements

Required

  • fzf - Interactive fuzzy finder (core dependency)

Optional (Highly Recommended)

Install these for the best experience:

Tool Purpose Fallback
fd Fast file finder find
ripgrep (rg) Lightning-fast content search grep
bat or batcat Syntax-highlighted previews cat
eza Modern directory trees tree or basic display
tree Directory structure visualization Basic display

Note: To see icons in directory trees when using eza, you need to install a Nerd Font. Popular choices include:

After installation, configure your terminal to use the Nerd Font.

πŸ“¦ Installing Dependencies

macOS (Homebrew)

brew install fzf fd ripgrep bat eza tree

Ubuntu/Debian

sudo apt update
sudo apt install fzf fd-find ripgrep bat eza tree

πŸš€ Installation

Method 1: Quick Install (Recommended)

curl -fsSL https://raw.githubusercontent.com/the0807/ff/main/install.sh | bash

Then reload your shell:

source ~/.zshrc   # or ~/.bashrc for bash users

Method 2: Manual Install

  1. Download the script:
curl -fsSL https://raw.githubusercontent.com/the0807/ff/main/ff.sh -o ~/.ff.sh
  1. Add to your shell configuration:

For Zsh (~/.zshrc):

echo 'source ~/.ff.sh' >> ~/.zshrc
source ~/.zshrc

For Bash (~/.bashrc or ~/.bash_profile on macOS):

echo 'source ~/.ff.sh' >> ~/.bashrc
source ~/.bashrc

πŸ“– Usage

Basic Commands

ff          # Start in Find mode (default)
ff find     # Start in Find mode (explicit)
ff grep     # Start in Grep mode

Key Bindings

Common Controls

Key Action
Enter Navigate to file/directory
Ctrl-O Open file in editor (at matched line in Grep mode)
TAB Toggle between Find and Grep mode
Ctrl-U Scroll preview up
Ctrl-D Scroll preview down
Esc Exit
Ctrl-C Cancel/Exit

Find Mode

  • Type to fuzzy search by filename
  • Press Enter to navigate to the selected file's directory
  • Press Ctrl-O to open the file in your editor

Grep Mode

  • Type to search by file content
  • See matching files with line numbers and context
  • Press Enter to navigate to the file's directory
  • Press Ctrl-O to open the file at the matched line

🎨 Usage Examples

Example 1: Quick File Search

$ ff
# Type "config" to fuzzy find files matching "config"
# Use arrow keys to select
# Press Enter to cd to the file's directory
# Or press Ctrl-O to open the file

Example 2: Search Code Content

$ ff grep
# Type "function handleClick"
# See all files containing this text
# Files show with line numbers highlighted
# Press Ctrl-O to open in editor at that exact line

Example 3: Dynamic Mode Switching

$ ff
# Start browsing files in Find mode
# Type "README" to find README files
# Press TAB to switch to Grep mode
# Type "installation" to search content
# Press TAB again to return to Find mode

Example 4: Navigation Workflow

$ ff find
# Search for "utils.js"
# Press Enter to cd to the directory
$ pwd  # You're now in the file's directory

βš™οΈ Customization

Change Default Editor

By default, ff uses VSCode (code) if available, otherwise falls back to $EDITOR. To customize:

# Add to ~/.zshrc or ~/.bashrc
export EDITOR=nvim     # Neovim
# or
export EDITOR=vim      # Vim
# or
export EDITOR=nano     # Nano

Modify Search Behavior

Edit the ff.sh file to customize:

  • FZF options (layout, theme, colors)
  • Preview window size and position
  • Key bindings
  • Search commands

🎯 How It Works

Find Mode

  1. Uses fd (or find) to list all files and directories
  2. Pipes results to fzf for interactive filtering
  3. Shows file previews using bat (with syntax highlighting)
  4. Shows directory trees using eza or tree

Grep Mode

  1. Uses ripgrep (or grep) to search file contents as you type
  2. Results show filename, line number, and matched content
  3. Preview highlights the matched line in context
  4. Opening with Ctrl-O jumps directly to the matched line

πŸ”§ Troubleshooting

"fzf not found" error

# Check if fzf is installed
which fzf

# If not installed, install it:
# macOS
brew install fzf

# Ubuntu/Debian
sudo apt install fzf

Preview not displaying properly

Install the optional tools for better previews:

# macOS
brew install bat eza tree

# Ubuntu/Debian
sudo apt install bat eza tree

Editor not opening files

Check your EDITOR environment variable:

echo $EDITOR

# If empty or not your preferred editor, set it:
export EDITOR=vim  # or your preferred editor

VSCode not opening at the correct line

Ensure VSCode command-line tools are installed:

  1. Open VSCode
  2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Linux/Windows)
  3. Type "Shell Command: Install 'code' command in PATH"
  4. Select it and restart your terminal

🀝 Contributing

Contributions are welcome! Feel free to:

  • πŸ› Report bugs by opening an issue
  • πŸ’‘ Suggest new features
  • πŸ”§ Submit pull requests
  • πŸ“– Improve documentation

πŸ“„ License

MIT License - Feel free to use, modify, and distribute.

πŸ™ Acknowledgments

This project is built on top of these excellent tools:

  • fzf - Command-line fuzzy finder
  • fd - Fast and user-friendly alternative to find
  • ripgrep - Recursively search directories for regex patterns
  • bat - Cat clone with syntax highlighting
  • eza - Modern replacement for ls

πŸ’‘ Tips & Tricks

Tip 1: Quick Project Navigation

# From anywhere in your project
ff
# Type the filename you want to work on
# Press Enter to navigate there
# Your shell is now in that directory!

Tip 2: Finding TODO Comments

ff grep
# Type "TODO"
# See all TODO comments across your codebase
# Press Ctrl-O to open and fix them

Tip 3: Configuration File Hunting

ff
# Type "config"
# Quickly find all configuration files

Tip 4: Searching for Functions

ff grep
# Type "function myFunction"
# Find where functions are defined
# Jump directly to the definition

πŸ“Š Performance

ff is designed to be fast even in large codebases:

  • With fd and ripgrep: Handles repositories with 100,000+ files efficiently
  • Real-time search results as you type
  • Minimal memory footprint
  • Works great on both small and large projects

Happy file browsing! πŸš€

About

πŸ” An interactive file search and navigation tool using fzf

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages