Terminal GuideTerminal Guide

McFly

Modern CLI
macOSLinux
Rust

Intelligent shell history search with neural network.

Official Website

Features

Neural NetworkContext AwareShell IntegrationFuzzy Search
Replaces
history

Installation

Homebrew
brew install mcfly
Pacman (Arch)
pacman -S mcfly
Cargo (Rust)
cargo install mcfly

Why use McFly?

McFly is an intelligent shell history search tool that learns from your behavior. Instead of showing the most recent commands, it uses machine learning to rank commands by relevance to your current context, making it faster and easier to find the command you need.

Neural Network Learning

McFly uses machine learning to understand your command patterns and preferences, continuously improving suggestions.

Context-Aware Search

Ranks commands based on your current directory, recent usage, and other contextual factors.

Fuzzy Search

Fast fuzzy matching for finding commands even when you don't remember the exact syntax.

Better Than Ctrl+R

Superior to the default history search with intelligent ranking and easier navigation.

Installation

Using Homebrew (macOS/Linux)

Installation
brew install mcfly

Using Cargo (Rust)

Installation
cargo install mcfly

Shell Integration Setup

Shell Setup
# For Bash, add to ~/.bashrc:
eval "$(mcfly init bash)"

# For Zsh, add to ~/.zshrc:
eval "$(mcfly init zsh)"

# For Fish, add to ~/.config/fish/config.fish:
mcfly init fish | source

# Then restart your shell or source your config
source ~/.bashrc  # or ~/.zshrc

Verify Installation

Verification
mcfly --version

# Check if integrated with your shell
echo $MCFLY_HOME  # Should show McFly's data directory

Basic Usage

Searching History

Basic Search
# Open McFly search interface (replaces Ctrl+R)
Ctrl+R

# Or explicitly search for commands
mcfly search "git commit"

# Search with fuzzy matching
Ctrl+R
# Type partial command: gst
# McFly shows: git status, git stash, etc.

Navigation and Selection

Navigation
# In McFly search interface:
Ctrl+R              # Open search
Type: command       # Fuzzy search
↑/↓                # Navigate results
Enter               # Execute selected command
Esc                 # Cancel search

# Preview commands
Ctrl+O              # Show more details about highlighted command
Tab                 # Select/deselect commands (multi-select)

Learning from Your Habits

Learning Process
# McFly learns as you use it:
# 1. Every command execution is recorded
# 2. Usage patterns are analyzed
# 3. Suggestions are ranked based on:
#    - Directory context
#    - Recent usage frequency
#    - Time patterns
#    - Command success/failure

# The more you use it, the better suggestions become
# After a few weeks of normal usage, suggestions will be highly personalized

Common Commands and Options

Command/OptionDescriptionExample
mcfly searchSearch command historymcfly search "git"
mcfly initInitialize shell integrationmcfly init bash
--helpShow help informationmcfly --help
--versionShow version informationmcfly --version
MCFLY_HOMESet data directory locationexport MCFLY_HOME=~/.mcfly

Practical Examples

Git Workflow Example

Git Workflow
# After using these commands several times:
git add .
git commit -m "Add feature"
git push

# Later, just press Ctrl+R and type:
Ctrl+R
git c
# McFly shows: git commit (at top, as it's most used in this context)

Ctrl+R
gp
# McFly shows: git push (learns your patterns)

Directory-Aware Suggestions

Context-Aware Behavior
# When in your project directory:
Ctrl+R
npm
# McFly suggests: npm install, npm start, npm test

# When in a different project directory:
Ctrl+R
npm
# McFly suggests different npm commands based on what you usually do there

# The learning is context-aware per directory

Complex Command Recovery

Complex Commands
# You used a complex command weeks ago:
ffmpeg -i input.mp4 -c:v libx265 -crf 23 output.mp4

# Recover it without remembering exact syntax:
Ctrl+R
ffmpeg
# McFly shows your previous ffmpeg commands ranked by relevance

# Or search for partial pattern:
Ctrl+R
265
# Finds the HEVC encoding command

Developer Tools Integration

Development Tools
# Docker commands with context
Ctrl+R
docker run
# Shows your frequently used docker commands

# Kubernetes operations
Ctrl+R
kubectl apply
# Shows your kubectl patterns

# Python development
Ctrl+R
pytest
# McFly learns your testing patterns

Configuration and Customization

Environment Variables

Environment Setup
# Set McFly data directory
export MCFLY_HOME="$HOME/.config/mcfly"

# Configure history file location
export HISTFILE="$HOME/.history"

# Control number of results shown
export MCFLY_RESULTS=20

# Add to ~/.bashrc or ~/.zshrc
# These variables control McFly's behavior and data storage

Shell-Specific Configuration

Shell Config
# For Bash, customize in ~/.bashrc:
eval "$(mcfly init bash)"

# For Zsh, customize in ~/.zshrc:
eval "$(mcfly init zsh)"

# For Fish, customize in ~/.config/fish/config.fish:
mcfly init fish | source

# Keybinding customization (shell-specific)
# Bash: Use bind command
# Zsh: Use bindkey command
# Fish: Built-in keybinding setup

Import Existing History

History Import
# McFly automatically imports your existing shell history on first run

# If you want to re-import or migrate:
mcfly import

# This helps bootstrap the machine learning model with your past commands
# After import, McFly learns patterns from your entire history

McFly vs Traditional History Search

FeatureCtrl+R (Default)fzfMcFly
Fuzzy searchNoYesYes
Learning/RankingNoneFrequency onlyNeural network
Context awarenessNoNoYes
Setup complexityNoneModerateSimple
Learning curveNoneMinimalMinimal
Improves over timeNoNoYes

Tips

  • McFly automatically replaces the default Ctrl+R behavior, so no keybinding changes are needed
  • The neural network model improves significantly after 2-4 weeks of regular use, giving increasingly accurate suggestions
  • McFly learns per-directory patterns, so behavior in different projects becomes increasingly specialized
  • You can use Tab to select multiple commands at once, useful for batch operations
  • McFly stores command history in a database format, making it more reliable than plain text history files
  • Consider using McFly with other history tools like zsh-autosuggestions for a complementary workflow
  • If migration from fzf + history, McFly's context awareness makes it worth the switch for discovering commands you forgot about
Written by Dai AokiPublished: 2026-01-20

Related Articles

Explore More