mcfly

An upgraded shell history search that replaces ctrl-r, using a small neural network to prioritize results based on context.

McFly replaces your default ctrl-r shell history search with an intelligent search interface. Rather than showing results in simple chronological order, it trains a small neural network on your usage patterns and prioritises commands based on your current working directory, recently used commands, and how often a command has been run — and failed.

Features

  • Neural network ranking — results are sorted by relevance, not just recency
  • Context-aware — considers your current directory and recent command history when scoring suggestions
  • Failure tracking — commands that exited with a non-zero status are ranked down automatically
  • Fuzzy search — find commands even with partial or approximate input
  • Supports bash, zsh, and fish
  • Lightweight SQLite database — your history is stored locally, no cloud involved

Installation

cargo install mcfly

Or via package managers:

# macOS
brew install mcfly

# Arch Linux
pacman -S mcfly

# Debian / Ubuntu (Debian 12+)
apt install mcfly

# Fedora
dnf install mcfly

Setup

After installing, add the following to your shell's config file:

# bash (~/.bashrc)
eval "$(mcfly init bash)"

# zsh (~/.zshrc)
eval "$(mcfly init zsh)"

# fish (~/.config/fish/config.fish)
mcfly init fish | source

Then restart your shell (or source the config file) and press ctrl-r to start using McFly.

Usage

Simply press ctrl-r as you normally would. McFly opens an interactive search UI over your history. Type to filter, use arrow keys to navigate, and press Enter to run or Tab to paste the command into your prompt without running it.

# Run a search directly from the command line
mcfly search "cargo build"

# Add a command to the history manually
mcfly add -- "some command"

Tips

  • The more you use it, the smarter it gets — the neural network improves as it learns your patterns.
  • Set MCFLY_RESULTS=50 in your environment to show more results in the UI.
  • Set MCFLY_INTERFACE_VIEW=BOTTOM if you prefer the search box at the bottom of the screen.
  • McFly works well alongside zoxide — between the two, navigating your shell history and directory history becomes effortless.