Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mcfly

> 编程语言
Open source

Fly through your shell history. Great Scott!

7.8K stars0 likes1 views
WebsiteGitHub

About

Fly through your shell history. Great Scott!

Seeking co-maintainers: I don't have much time to maintain this project these days. If someone would like to jump in and become a co-maintainer, it would be appreciated!

McFly - fly through your shell history

McFly replaces your default ctrl-r shell history search with an intelligent search engine that takes into account your working directory and the context of recently executed commands. McFly's suggestions are prioritized in real time with a small neural network.

TL;DR: an upgraded ctrl-r where history results make sense for what you're working on right now.

Features

  • Rebinds ctrl-r to bring up a full-screen reverse history search prioritized with a small neural network.
  • Augments your shell history to track command exit status, timestamp, and execution directory in a SQLite database.
  • Maintains your normal shell history file as well so that you can stop using McFly whenever you want.
  • Unicode support throughout.
  • Includes a simple action to scrub any history item from the McFly database and your shell history files.
  • Designed to be extensible for other shells in the future.
  • Written in Rust, so it's fast and safe.
  • You can type % to match any number of characters when searching.
  • Supports Zsh, Bash (version 3+), and PowerShell (version 7+)

Prioritization

The key feature of McFly is smart command prioritization powered by a small neural network that runs in real time. The goal is for the command you want to run to always be one of the top suggestions.

When suggesting a command, McFly takes into consideration:

  • The directory where you ran the command. You're likely to run that command in the same directory in the future.
  • What commands you typed before the command (e.g., the command's execution context).
  • How often you run the command.
  • When you last ran the command.
  • If you've selected the command in McFly before.
  • The command's historical exit status. You probably don't want to run old failed commands.

Installation

Install with Homebrew (on macOS or Linux)

  1. Install mcfly:

    bash
    brew install mcfly
  2. Add the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file:

    Bash:

    bash
    eval "$(mcfly init bash)"

    Zsh:

    bash
    eval "$(mcfly init zsh)"

    Fish:

    bash
    mcfly init fish | source
  3. Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.

Uninstalling with Homebrew

  1. Remove mcfly:
    bash
    brew uninstall mcfly
  2. Remove the lines you added to ~/.bashrc / ~/.zshrc / ~/.config/fish/config.fish.

Install with MacPorts (on macOS)

  1. Update the ports tree

    bash
    sudo port selfupdate
  2. Install mcfly:

    bash
    sudo port install mcfly
  3. Add the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file, as appropriate:

    Bash:

    bash
    eval "$(mcfly init bash)"

    Zsh:

    bash
    eval "$(mcfly init zsh)"

    Fish:

    bash
    mcfly init fish | source
  4. Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.

Uninstalling with MacPorts

  1. Remove mcfly:
    bash
    sudo port uninstall mcfly
  2. Remove the lines you added to ~/.bashrc / ~/.zshrc / ~/.config/fish/config.fish.

Install using WinGet on Windows (we do not maintain this install script and cannot vouch for its accuracy or safety)

  1. Install mcfly:
    bash
    winget install AndrewCantino.McFly
  2. Add the following to your $PROFILE:
    bash
    Invoke-Expression -Command $(mcfly init powershell | Out-String)
  3. Restart your terminal

Uninstall using Winget

  1. Remove mcfly:
    bash
    winget uninstall AndrewCantino.McFly
  2. Remove the lines you added to $PROFILE.

Installing using our install script (macOS or Linux)

  1. curl -LSfs https://raw.githubusercontent.com/cantino/mcfly/master/ci/install.sh | sh -s -- --git cantino/mcfly (or, if the current user doesn't have permissions to edit /usr/local/bin, then use sudo sh -s.)

  2. Add the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file, respectively:

    Bash:

    bash
    eval "$(mcfly init bash)"

    Zsh:

    bash
    eval "$(mcfly init zsh)"

    Fish:

    bash
    mcfly init fish | source
  3. Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.

Installing manually from GitHub (macOS or Linux)

  1. Download the latest release from GitHub.

  2. Install to a location in your $PATH. (For example, you could create a directory at ~/bin, copy mcfly to this location, and add export PATH="$PATH:$HOME/bin" to your .bashrc / .zshrc, or run set -Ua fish_user_paths "$HOME/bin" for fish.)

  3. Add the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish, respectively:

    Bash:

    bash
    eval "$(mcfly init bash)"

    Zsh:

    bash
    eval "$(mcfly init zsh)"

    Fish:

    bash
    mcfly init fish | source
  4. Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.

Install manually from source (macOS, Linux, or Windows)

  1. Install Rust 1.40 or later

  2. Run git clone https://github.com/cantino/mcfly and cd mcfly

  3. Run cargo install --path .

  4. Ensure ~/.cargo/bin is in your $PATH.

  5. Add the following to the end of your ~/.bashrc, ~/.zshrc, ~/.config/fish/config.fish, or powershell $PROFILE, respectively:

    Bash:

    bash
    eval "$(mcfly init bash)"

    Zsh:

    bash
    eval "$(mcfly init zsh)"

    Fish:

    bash
    mcfly init fish | source

    Powershell Core (pwsh)

    powershell
    Invoke-Expression -Command $(mcfly init powershell | out-string)
  6. Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish / . $PROFILE or restart your terminal emulator.

Install by Zinit

  • Add below code to your zshrc.

    bash
    zinit ice lucid wait"0a" from"gh-r" as"program" atload'eval "$(mcfly init zsh)"'
    zinit light cantino/mcfly
  • It will download mcfly and install for you.

  • $(mcfly init zsh) will be executed after prompt

iTerm2

To avoid McFly's UI messing up your scrollback history in iTerm2, make sure this option is unchecked:

Dump history

McFly can dump the command history into stdout.

For example:

bash
mcfly dump --since '2023-01-01' --before '2023-09-12 09:15:30'

will dump the command run between 2023-01-01 00:00:00.0 to 2023-09-12 09:15:30(exclusive) as json. You can specify csv as dump format via --format csv as well.

Each item in dumped commands has the following fields:

  • cmd: The run command.
  • when_run: The time when the command ran in your local timezone.

You can dump all the commands history without any arguments:

bash
mcfly dump

Timestamp format

McFly parses timestamps via chrono-systemd-time, a non-strict implementation of systemd.time, with the following exceptions:

  • time units must accompany all time span values.
  • time zone suffixes are not supported.
  • weekday prefixes are not supported.

McFly users simply need to understand specifying timezone in timestamp isn't allowed. McFly will always use your local timezone.

For more details, please refer to the chrono-systemd-time documentation.

Regex

Dump supports filtering commands with regex. The regex syntax follows crate regex.

For example:

bash
mcfly dump -r '^cargo run'

will dump all command prefixes with cargo run.

You can use -r/--regex and time options at the same time.

For example:

bash
mcfly dump -r '^cargo run' --since '2023-09-12 09:15:30'

will dump all command prefixes with cargo run ran since 2023-09-12 09:15:30.

Settings

A number of settings can be set via environment variables. To set a setting you should add the following snippets to your ~/.bashrc / ~/.zshrc / ~/.config/fish/config.fish.

Color settings can be set in a config file, which will be in ~/.mcfly if it exists, otherwise in $XDG_DATA_DIR/mcfly. On MacOS, this would be ~/Library/Application Support/McFly/config.toml.

Light Mode

To swap the color scheme for use in a light terminal, set the environment variable MCFLY_LIGHT.

bash / zsh:

bash
export MCFLY_LIGHT=TRUE

fish:

bash
set -gx MCFLY_LIGHT TRUE

powershell:

powershell
$env:MCFLY_LIGHT = "TRUE"

Tip: on macOS you can use the following snippet for color scheme to be configured based on system-wide settings:

bash / zsh:

bash
if [[ "$(defaults read -g AppleInterfaceStyle 2&>/dev/null)" != "Dark" ]]; then
    export MCFLY_LIGHT=TRUE
fi

VIM Key Scheme

By default Mcfly uses an emacs inspired key scheme. If you would like to switch to the vim inspired key scheme, set the environment variable MCFLY_KEY_SCHEME.

bash / zsh:

bash
export MCFLY_KEY_SCHEME=vim

fish:

bash
set -gx MCFLY_KEY_SCHEME vim

powershell:

powershell
$env:MCFLY_KEY_SCHEME="vim"

Fuzzy Searching

To enable fuzzy searching, set MCFLY_FUZZY to an integer. 0 is off; higher numbers weight toward shorter matches. Values in the 2-5 range get good results so far; try a few and report what works best for you!

bash / zsh:

bash
export MCFLY_FUZZY=2

fish:

bash
set -gx MCFLY_FUZZY 2

powershell:

powershell
$env:MCFLY_FUZZY=2

Results Count

To change the maximum number of results shown, set MCFLY_RESULTS (default: 30).

bash / zsh:

bash
export MCFLY_RESULTS=50

fish:

bash
set -gx MCFLY_RESULTS 50

powershell:

powershell
$env:MCFLY_RESULTS=50

Delete without confirmation

To delete without confirmation, set MCFLY_DELETE_WITHOUT_CONFIRM to true.

bash / zsh:

bash
export MCFLY_DELETE_WITHOUT_CONFIRM=true

fish:

bash
set -gx MCFLY_DELETE_WITHOUT_CONFIRM true

powershell:

powershell
$env:MCFLY_DELETE_WITHOUT_CONFIRM="true"

Interface view

To change interface view, set MCFLY_INTERFACE_VIEW (default: TOP). Available options: TOP and BOTTOM

bash / zsh:

bash
export MCFLY_INTERFACE_VIEW=BOTTOM

fish:

bash
set -gx MCFLY_INTERFACE_VIEW BOTTOM

powershell:

powershell
$env:MCFLY_INTERFACE_VIEW="BOTTOM"

Disable menu interface

To disable the menu interface, set the environment variable MCFLY_DISABLE_MENU.

bash / zsh:

bash
export MCFLY_DISABLE_MENU=TRUE

fish:

bash
set -gx MCFLY_DISABLE_MENU TRUE

powershell:

powershell
$env:MCFLY_DISABLE_MENU=true

Results sorting

To change the sorting of results shown, set MCFLY_RESULTS_SORT (default: RANK). Possible values RANK and LAST_RUN

bash / zsh:

bash
export MCFLY_RESULTS_SORT=LAST_RUN

fish:

bash
set -gx MCFLY_RESULTS_SORT LAST_RUN

powershell:

powershell
$env:MCFLY_RESULTS_SORT="LAST_RUN"

Custom Prompt

To change the prompt, set MCFLY_PROMPT (default: $).

bash / zsh:

bash
export MCFLY_PROMPT="❯"

fish:

bash
set -gx MCFLY_PROMPT "❯"

powershell:

powershell
$env:MCFLY_PROMPT=">"

Note that only single-character-prompts are allowed. setting MCFLY_PROMPT to "<str>" will reset it to the default prompt.

Ig

Issues· 135 open

View all issuesOpen on GitHub
  • #465

    Fuzzy matching unintuitive

    Updated Jul 9, 2026
  • #494

    mcfly init powershell hangs in non-interactive sessions due to Install-Module PSReadLine

    Updated Jun 28, 2026
  • #117

    Nushell support?

    help wantedUpdated Apr 27, 2026
  • #269

    Confusion about XDG Base Directory specification and what is $XDG_DATA_DIR?

    Updated Feb 23, 2026
  • #478

    Ctrl-R shortcut: please make it configurable

    Updated Feb 23, 2026
  • #480

    Conflicts with `PROMPT_COMMAND='history -a'` hook so that `up` does not returns the previous command :(

    Updated Feb 20, 2026
  • #479

    Default bright blue color is difficult to read :(

    Updated Feb 20, 2026
  • #470

    mcfly.bash unbinds \C-g

    Updated Jan 18, 2026
  • #411

    Add an X86_64 build for linux

    Updated Dec 24, 2025
  • #469

    Can't run any command after MacOS update

    Updated Oct 2, 2025

> Tags

Rusthistoryrustsearchshell

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言