Searching through shell command history is an indispensable part of terminal productivity. The default reverse search mechanism in Bash and Zsh—triggered via Ctrl + R—relies on basic chronological substring matching. If you ran a complex ffmpeg, docker, or kubectl command weeks ago in a specific repository, repeatedly tapping Ctrl + R cycles through dozens of unrelated invocations before surfacing the command you actually need. McFly transforms this experience by introducing an intelligent, neural network-driven history search engine.
Written in Rust and backed by a lightweight on-device neural network and an embedded SQLite database, McFly analyses your execution context—including your current directory, recent command exit statuses, and frequency patterns—to predict which command you are most likely seeking.
How McFly’s Intelligent Ranking Works
Unlike standard text greppers that sort commands strictly by timestamp, McFly’s machine learning model ranks command candidates according to contextual relevance:
- Working Directory Context: Commands executed in your current directory (or similar repository trees) receive higher priority scores.
- Command Execution Frequency: Commands you run regularly are weighted against one-off typos.
- Recent Exit Status: Commands that terminated with a successful exit code (
0) are prioritised over failed commands that produced syntax errors. - Temporal Recency: Commands executed recently receive appropriate recency boosts without completely burying historical favorites.
- Interactive Terminal UI: Replaces the obscure one-line reverse search prompt with a navigable, colourised full-screen terminal popup.
How to Install McFly on Linux
McFly is available across mainstream Linux package managers or via a pre-compiled standalone binary script.
1. Automated Binary Installation (Recommended)
The fastest way to install McFly across any Linux distribution is via the official installation script:
curl -LSfs https://raw.githubusercontent.com/cantino/mcfly/master/ci/install.sh | sudo sh -s -- --git cantino/mcfly
This script automatically identifies your CPU architecture (x86_64 or ARM64) and places the compiled binary in /usr/local/bin/mcfly.
2. Arch Linux and Manjaro
Install directly from the official Arch Community repositories:
sudo pacman -S mcfly
3. Fedora and RHEL Derivatives
Install via the Fedora Copr repository or Cargo:
sudo dnf copr enable agriffis/mcfly
sudo dnf install mcfly
4. Compiling via Cargo (Rust Toolchain)
cargo install mcfly
Configuring Shell Integration
After installing the binary, you must bind McFly to your shell so it can capture command telemetry and intercept the standard Ctrl + R shortcut.
For Bash Users
Append the initialisation hook to ~/.bashrc:
echo 'eval "$(mcfly init bash)"' >> ~/.bashrc
source ~/.bashrc
For Zsh Users
Append the hook to ~/.zshrc:
echo 'eval "$(mcfly init zsh)"' >> ~/.zshrc
source ~/.zshrc
For Fish Users
Add the initialisation directive to your Fish config:
echo 'mcfly init fish | source' >> ~/.config/fish/config.fish
Using McFly for Intelligent Command Search
Once initialised, press Ctrl + R in your terminal prompt. McFly launches an interactive interface showing candidate commands ranked with confidence percentages.
Essential navigation controls:
- Typing: Type any search term to narrow down commands in real time.
- Arrow Keys (
Up/Down): Navigate through ranked suggestions. Tab: Edit the selected command in your prompt without executing it immediately.Enter: Execute the selected command immediately.Delete(orFn + Backspace): Permanently delete an errant command from your history database.Esc: Exit McFly and return to your empty terminal prompt.
McFly Interactive Shortcuts Reference
| Keybinding | Function | Productivity Benefit |
|---|---|---|
Ctrl + R |
Launch McFly | Intercepts standard shell reverse-i-search with AI ranking. |
Enter |
Run Immediately | Executes the highlighted command in your current shell. |
Tab |
Place in Buffer | Populates shell line editor to tweak flags before running. |
F1 / F2 |
Toggle Directory Filter | Switches between searching commands from the current directory vs globally. |
Delete |
Purge History Entry | Removes sensitive tokens or mistyped commands permanently. |
Esc / Ctrl + C |
Cancel | Aborts search and leaves terminal state unchanged. |
Customising McFly Environment Settings
You can fine-tune McFly’s visual presentation and behaviour by setting environment variables in your ~/.bashrc or ~/.zshrc:
1. Customising Interface Themes and Colors
# Available schemes: default, dark, light, bw
export MCFLY_KEY_SCHEME=vim
export MCFLY_LIGHT=FALSE
2. Limiting Results and Prompt Placement
By default, McFly places its search bar at the top or bottom of the screen depending on your prompt location:
# Display search bar at the bottom
export MCFLY_PROMPT="BOTTOM"
# Show up to 15 suggestions
export MCFLY_RESULTS=15
3. Disabling Shell History Truncation
Unlike standard shell history logs that cap at 1,000 or 5,000 commands, McFly stores commands indefinitely in SQLite (~/.local/share/mcfly/history.db). To ensure standard Bash history does not truncate, add:
export HISTSIZE=100000
export HISTFILESIZE=200000