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 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.
ctrl-r to bring up a full-screen reverse history search prioritized with a small neural network.% to match any number of characters when searching.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:
Install mcfly:
brew install mcflyAdd the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file:
Bash:
eval "$(mcfly init bash)"Zsh:
eval "$(mcfly init zsh)"Fish:
mcfly init fish | sourceRun . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.
mcfly:brew uninstall mcfly~/.bashrc / ~/.zshrc / ~/.config/fish/config.fish.Update the ports tree
sudo port selfupdateInstall mcfly:
sudo port install mcflyAdd the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file, as appropriate:
Bash:
eval "$(mcfly init bash)"Zsh:
eval "$(mcfly init zsh)"Fish:
mcfly init fish | sourceRun . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.
mcfly:sudo port uninstall mcfly~/.bashrc / ~/.zshrc / ~/.config/fish/config.fish.mcfly:winget install AndrewCantino.McFly$PROFILE:Invoke-Expression -Command $(mcfly init powershell | Out-String)mcfly:winget uninstall AndrewCantino.McFly$PROFILE.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.)
Add the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file, respectively:
Bash:
eval "$(mcfly init bash)"Zsh:
eval "$(mcfly init zsh)"Fish:
mcfly init fish | sourceRun . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.
Download the latest release from GitHub.
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.)
Add the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish, respectively:
Bash:
eval "$(mcfly init bash)"Zsh:
eval "$(mcfly init zsh)"Fish:
mcfly init fish | sourceRun . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.
Run git clone https://github.com/cantino/mcfly and cd mcfly
Run cargo install --path .
Ensure ~/.cargo/bin is in your $PATH.
Add the following to the end of your ~/.bashrc, ~/.zshrc, ~/.config/fish/config.fish, or powershell $PROFILE, respectively:
Bash:
eval "$(mcfly init bash)"Zsh:
eval "$(mcfly init zsh)"Fish:
mcfly init fish | sourcePowershell Core (pwsh)
Invoke-Expression -Command $(mcfly init powershell | out-string)Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish / . $PROFILE or restart your terminal emulator.
Add below code to your zshrc.
zinit ice lucid wait"0a" from"gh-r" as"program" atload'eval "$(mcfly init zsh)"'
zinit light cantino/mcflyIt will download mcfly and install for you.
$(mcfly init zsh) will be executed after prompt
To avoid McFly's UI messing up your scrollback history in iTerm2, make sure this option is unchecked:
McFly can dump the command history into stdout.
For example:
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:
mcfly dumpMcFly parses timestamps via chrono-systemd-time, a non-strict implementation of systemd.time, with the following exceptions:
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.
Dump supports filtering commands with regex. The regex syntax follows crate regex.
For example:
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:
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.
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.
To swap the color scheme for use in a light terminal, set the environment variable MCFLY_LIGHT.
bash / zsh:
export MCFLY_LIGHT=TRUEfish:
set -gx MCFLY_LIGHT TRUEpowershell:
$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:
if [[ "$(defaults read -g AppleInterfaceStyle 2&>/dev/null)" != "Dark" ]]; then
export MCFLY_LIGHT=TRUE
fiBy 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:
export MCFLY_KEY_SCHEME=vimfish:
set -gx MCFLY_KEY_SCHEME vimpowershell:
$env:MCFLY_KEY_SCHEME="vim"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:
export MCFLY_FUZZY=2fish:
set -gx MCFLY_FUZZY 2powershell:
$env:MCFLY_FUZZY=2To change the maximum number of results shown, set MCFLY_RESULTS (default: 30).
bash / zsh:
export MCFLY_RESULTS=50fish:
set -gx MCFLY_RESULTS 50powershell:
$env:MCFLY_RESULTS=50To delete without confirmation, set MCFLY_DELETE_WITHOUT_CONFIRM to true.
bash / zsh:
export MCFLY_DELETE_WITHOUT_CONFIRM=truefish:
set -gx MCFLY_DELETE_WITHOUT_CONFIRM truepowershell:
$env:MCFLY_DELETE_WITHOUT_CONFIRM="true"To change interface view, set MCFLY_INTERFACE_VIEW (default: TOP).
Available options: TOP and BOTTOM
bash / zsh:
export MCFLY_INTERFACE_VIEW=BOTTOMfish:
set -gx MCFLY_INTERFACE_VIEW BOTTOMpowershell:
$env:MCFLY_INTERFACE_VIEW="BOTTOM"To disable the menu interface, set the environment variable MCFLY_DISABLE_MENU.
bash / zsh:
export MCFLY_DISABLE_MENU=TRUEfish:
set -gx MCFLY_DISABLE_MENU TRUEpowershell:
$env:MCFLY_DISABLE_MENU=trueTo change the sorting of results shown, set MCFLY_RESULTS_SORT (default: RANK).
Possible values RANK and LAST_RUN
bash / zsh:
export MCFLY_RESULTS_SORT=LAST_RUNfish:
set -gx MCFLY_RESULTS_SORT LAST_RUNpowershell:
$env:MCFLY_RESULTS_SORT="LAST_RUN"To change the prompt, set MCFLY_PROMPT (default: $).
bash / zsh:
export MCFLY_PROMPT="❯"fish:
set -gx MCFLY_PROMPT "❯"powershell:
$env:MCFLY_PROMPT=">"Note that only single-character-prompts are allowed. setting MCFLY_PROMPT to "<str>" will reset it to the default prompt.
Fuzzy matching unintuitive
mcfly init powershell hangs in non-interactive sessions due to Install-Module PSReadLine
Nushell support?
Confusion about XDG Base Directory specification and what is $XDG_DATA_DIR?
Ctrl-R shortcut: please make it configurable
Conflicts with `PROMPT_COMMAND='history -a'` hook so that `up` does not returns the previous command :(
Default bright blue color is difficult to read :(
mcfly.bash unbinds \C-g
Add an X86_64 build for linux
Can't run any command after MacOS update