McFly — Fly Through Your Shell History with Context-Aware Search
McFly replaces the default Ctrl-R reverse search in bash/zsh/fish with a neural-ranked, context-aware history finder that considers directory, exit status, and recency.
What it is
McFly replaces the default Ctrl-R reverse history search in bash, zsh, and fish with a context-aware, neural-ranked search. Instead of simple substring matching, McFly considers your current working directory, the exit status of previous commands, the time of day, and how recently you used each command to rank results.
McFly is for developers and sysadmins who run many commands across multiple projects and want their shell history to surface the right command in the right context.
The project is actively maintained with regular releases and a growing user community. Documentation covers common use cases, and the open-source nature means you can inspect the source code, contribute fixes, and adapt the tool to your specific requirements.
How it saves time or tokens
Default shell history search shows the most recent match regardless of context. If you run git push in 20 different repositories, Ctrl-R always shows the last one. McFly ranks the git push from your current directory higher because it understands context. This eliminates scrolling through irrelevant matches and reduces typo-driven re-runs.
How to use
- Install McFly via brew, cargo, or your package manager.
- Add the shell integration to your profile (bash, zsh, or fish).
- Press Ctrl-R to search with McFly instead of the default history search.
Example
# Install McFly
brew install mcfly
# Add to .zshrc
eval "$(mcfly init zsh)"
# Add to .bashrc
eval "$(mcfly init bash)"
# Add to fish config
mcfly init fish | source
# Usage: press Ctrl-R and start typing
# McFly ranks results by:
# - Current directory context
# - Command exit status (successful commands rank higher)
# - Recency and frequency
# - Time of day patterns
Related on TokRepo
- AI Tools for Coding -- Developer tools and shell utilities
- Featured Workflows -- Top workflows on TokRepo
Common pitfalls
- McFly stores its database in
~/.mcfly/. If you use multiple machines, history is not shared automatically. Each machine maintains its own context database. - The initial history import from
.bash_historyor.zsh_historylacks context metadata (directory, exit status). Context-aware ranking improves over time as McFly records new commands. - McFly intercepts Ctrl-R. If you prefer the default behavior in some sessions, set
MCFLY_DISABLE=1before sourcing the init script.
Before adopting this tool, evaluate whether it fits your team's existing workflow. Read the official documentation thoroughly, and start with a small proof-of-concept rather than a full migration. Community forums, GitHub issues, and Stack Overflow are valuable resources when you encounter edge cases not covered in the documentation.
Frequently Asked Questions
McFly uses a small neural network trained on your shell usage patterns. It considers the current working directory, command exit status (preferring successful commands), recency, frequency, and time-of-day patterns to rank results.
McFly supports bash, zsh, and fish. Each shell has a dedicated init command that sets up the Ctrl-R keybinding and command tracking.
No. McFly maintains its own SQLite database alongside your regular shell history. Your .bash_history or .zsh_history file is not modified. McFly imports existing history on first run.
Yes. Use mcfly search to find commands and delete them from the McFly database. You can also set MCFLY_HISTORY_LIMIT to cap the number of stored commands.
Yes. McFly is written in Rust, which gives it fast startup time and low memory usage. The neural ranking model is lightweight and runs in milliseconds.
Citations (3)
- McFly GitHub— McFly is a context-aware shell history search tool
- McFly README— Neural-ranked results considering directory, exit status, and recency
- Rust Language— Rust-based CLI tool design
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.