{"id":13395203,"url":"https://github.com/cantino/mcfly","last_synced_at":"2025-05-13T17:04:12.101Z","repository":{"id":37381816,"uuid":"141060161","full_name":"cantino/mcfly","owner":"cantino","description":"Fly through your shell history. Great Scott!","archived":false,"fork":false,"pushed_at":"2025-03-22T19:51:40.000Z","size":10952,"stargazers_count":7224,"open_issues_count":122,"forks_count":180,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-05-06T16:13:49.700Z","etag":null,"topics":["history","rust","search","shell"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cantino.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-15T21:37:37.000Z","updated_at":"2025-05-04T18:03:08.000Z","dependencies_parsed_at":"2023-02-15T09:01:02.652Z","dependency_job_id":"4b9bc2ca-4b4b-4a19-aecb-7c992121d85d","html_url":"https://github.com/cantino/mcfly","commit_stats":{"total_commits":505,"total_committers":69,"mean_commits":7.318840579710145,"dds":0.4237623762376238,"last_synced_commit":"76df5377528dda4544780ca194e14c01e7c938e7"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantino%2Fmcfly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantino%2Fmcfly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantino%2Fmcfly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantino%2Fmcfly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cantino","download_url":"https://codeload.github.com/cantino/mcfly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990456,"owners_count":21995773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["history","rust","search","shell"],"created_at":"2024-07-30T17:01:46.068Z","updated_at":"2025-05-13T17:04:12.029Z","avatar_url":"https://github.com/cantino.png","language":"Rust","funding_links":[],"categories":["Rust","Completions","Applications","Command Line","Tool","Plugins","Terminal Commands","Command-Line Productivity","Tools","应用程序 Applications","Linux station","shell","Table of Contents","\u003ca name=\"history\"\u003e\u003c/a\u003eHistory management","rust","Shell History","Fuzzy Finding \u0026 Search","Other"],"sub_categories":["ZSH on Windows","System tools","Dependency Management","TUI Tool","history search","Rust","系统工具 System tools","📟️ Cli tools","Terminal Utilities"],"readme":"\u003e **Seeking co-maintainers**:\n\u003e 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!\n\n![Build Status](https://github.com/cantino/mcfly/actions/workflows/mean_bean_ci.yml/badge.svg)\n[![](https://img.shields.io/crates/v/mcfly.svg)](https://crates.io/crates/mcfly)\n\n# McFly - fly through your shell history\n\n\u003cimg src=\"/docs/screenshot.png\" alt=\"screenshot\" width=\"400\"\u003e\n\nMcFly replaces your default `ctrl-r` shell history search with an intelligent search engine that takes into account\nyour working directory and the context of recently executed commands. McFly's suggestions are prioritized\nin real time with a small neural network.\n\nTL;DR: an upgraded `ctrl-r` where history results make sense for what you're working on right now.\n\n## Features\n\n* Rebinds `ctrl-r` to bring up a full-screen reverse history search prioritized with a small neural network.\n* Augments your shell history to track command exit status, timestamp, and execution directory in a SQLite database.\n* Maintains your normal shell history file as well so that you can stop using McFly whenever you want.\n* Unicode support throughout.\n* Includes a simple action to scrub any history item from the McFly database and your shell history files.\n* Designed to be extensible for other shells in the future.\n* Written in Rust, so it's fast and safe.\n* You can type `%` to match any number of characters when searching.\n* Supports Zsh, Bash (version 3+), and PowerShell (version 7+)\n\n## Prioritization\n\nThe key feature of McFly is smart command prioritization powered by a small neural network that runs\nin real time. The goal is for the command you want to run to always be one of the top suggestions.\n\nWhen suggesting a command, McFly takes into consideration:\n\n* The directory where you ran the command. You're likely to run that command in the same directory in the future.\n* What commands you typed before the command (e.g., the command's execution context).\n* How often you run the command.\n* When you last ran the command.\n* If you've selected the command in McFly before.\n* The command's historical exit status. You probably don't want to run old failed commands.\n\n## Installation\n\n### Install with Homebrew (on macOS or Linux)\n\n1. Install `mcfly`:\n    ```bash\n    brew install mcfly\n    ```\n1. Add the following to the end of your `~/.bashrc`, `~/.zshrc`, or `~/.config/fish/config.fish` file:\n\n   Bash:\n    ```bash\n    eval \"$(mcfly init bash)\"\n    ```\n\n   Zsh:\n    ```bash\n    eval \"$(mcfly init zsh)\"\n    ```\n\n   Fish:\n    ```bash\n    mcfly init fish | source\n    ```\n1. Run `. ~/.bashrc` / `. ~/.zshrc` / `source ~/.config/fish/config.fish` or restart your terminal emulator.\n\n#### Uninstalling with Homebrew\n\n1. Remove `mcfly`:\n    ```bash\n    brew uninstall mcfly\n    ```\n1. Remove the lines you added to `~/.bashrc` / `~/.zshrc` / `~/.config/fish/config.fish`.\n\n### Install with MacPorts (on macOS)\n\n1. Update the ports tree\n    ```bash\n    sudo port selfupdate\n    ```\n1. Install `mcfly`:\n    ```bash\n    sudo port install mcfly\n    ```\n1. Add the following to the end of your `~/.bashrc`, `~/.zshrc`, or `~/.config/fish/config.fish` file, as appropriate:\n\n   Bash:\n    ```bash\n    eval \"$(mcfly init bash)\"\n    ```\n\n   Zsh:\n    ```bash\n    eval \"$(mcfly init zsh)\"\n    ```\n\n   Fish:\n    ```bash\n    mcfly init fish | source\n    ```\n1. Run `. ~/.bashrc` / `. ~/.zshrc` / `source ~/.config/fish/config.fish` or restart your terminal emulator.\n\n#### Uninstalling with MacPorts\n\n1. Remove `mcfly`:\n    ```bash\n    sudo port uninstall mcfly\n    ```\n1. Remove the lines you added to `~/.bashrc` / `~/.zshrc` / `~/.config/fish/config.fish`.\n\n### Installing using our install script (macOS or Linux)\n\n1. `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`.)\n\n2. Add the following to the end of your `~/.bashrc`, `~/.zshrc`, or `~/.config/fish/config.fish` file, respectively:\n\n   Bash:\n\n   ```bash\n   eval \"$(mcfly init bash)\"\n   ```\n\n   Zsh:\n\n   ```bash\n   eval \"$(mcfly init zsh)\"\n   ```\n\n   Fish:\n   ```bash\n   mcfly init fish | source\n   ```\n\n3. Run `. ~/.bashrc` / `. ~/.zshrc` / `source ~/.config/fish/config.fish` or restart your terminal emulator.\n\n### Installing manually from GitHub (macOS or Linux)\n\n1. Download the [latest release from GitHub](https://github.com/cantino/mcfly/releases).\n1. 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.)\n1. Add the following to the end of your `~/.bashrc`, `~/.zshrc`, or `~/.config/fish/config.fish`, respectively:\n\n   Bash:\n    ```bash\n    eval \"$(mcfly init bash)\"\n    ```\n\n   Zsh:\n    ```bash\n    eval \"$(mcfly init zsh)\"\n    ```\n\n   Fish:\n    ```bash\n    mcfly init fish | source\n    ```\n\n1. Run `. ~/.bashrc` / `. ~/.zshrc` / `source ~/.config/fish/config.fish` or restart your terminal emulator.\n\n### Install manually from source (macOS, Linux, or Windows)\n\n1. [Install Rust 1.40 or later](https://www.rust-lang.org/tools/install)\n1. Run `git clone https://github.com/cantino/mcfly` and `cd mcfly`\n1. Run `cargo install --path .`\n1. Ensure `~/.cargo/bin` is in your `$PATH`.\n1. Add the following to the end of your `~/.bashrc`, `~/.zshrc`, `~/.config/fish/config.fish`, or powershell `$PROFILE`, respectively:\n\n   Bash:\n    ```bash\n    eval \"$(mcfly init bash)\"\n    ```\n\n   Zsh:\n    ```bash\n    eval \"$(mcfly init zsh)\"\n    ```\n\n   Fish:\n    ```bash\n    mcfly init fish | source\n    ```\n\n    Powershell Core (pwsh)\n    ```powershell\n    Invoke-Expression -Command $(mcfly init powershell | out-string)\n    ```\n\n1. Run `. ~/.bashrc` / `. ~/.zshrc` / `source ~/.config/fish/config.fish` / `. $PROFILE` or restart your terminal emulator.\n\n### Install by [Zinit](https://github.com/zdharma-continuum/zinit)\n\n* Add below code to your zshrc.\n\n    ```zsh\n    zinit ice lucid wait\"0a\" from\"gh-r\" as\"program\" atload'eval \"$(mcfly init zsh)\"'\n    zinit light cantino/mcfly\n    ```\n* It will download mcfly and install for you.\n* `$(mcfly init zsh)` will be executed after prompt\n\n## iTerm2\n\nTo avoid McFly's UI messing up your scrollback history in iTerm2, make sure this option is unchecked:\n\n\u003cimg src=\"/docs/iterm2.jpeg\" alt=\"iterm2 UI instructions\"\u003e\n\n## Dump history\n\nMcFly can dump the command history into *stdout*.\n\nFor example:\n```bash\nmcfly dump --since '2023-01-01' --before '2023-09-12 09:15:30'\n```\nwill dump the command run between *2023-01-01 00:00:00.0* to *2023-09-12 09:15:30*(**exclusive**) as **json**.\nYou can specify **csv** as dump format via `--format csv` as well.\n\nEach item in dumped commands has the following fields:\n* `cmd`: The run command.\n* `when_run`: The time when the command ran in your local timezone.\n\nYou can dump all the commands history without any arguments:\n```bash\nmcfly dump\n```\n\n### Timestamp format\n\nMcFly parses timestamps via `chrono-systemd-time`, a non-strict implementation of [systemd.time](https://www.freedesktop.org/software/systemd/man/systemd.time.html), with the following exceptions:\n* time units **must** accompany all time span values.\n* time zone suffixes are **not** supported.\n* weekday prefixes are **not** supported.\n\nMcFly users simply need to understand **specifying timezone in timestamp isn't allowed**.\nMcFly will always use your **local timezone**.\n\nFor more details, please refer to the [`chrono-systemd-time` documentation](https://docs.rs/chrono-systemd-time/latest/chrono_systemd_time/).\n\n### Regex\n*Dump* supports filtering commands with regex.\nThe regex syntax follows [crate regex](https://docs.rs/regex/latest/regex/#syntax).\n\nFor example:\n```bash\nmcfly dump -r '^cargo run'\n```\nwill dump all command prefixes with `cargo run`.\n\nYou can use `-r/--regex` and time options at the same time.\n\nFor example:\n```bash\nmcfly dump -r '^cargo run' --since '2023-09-12 09:15:30'\n```\nwill dump all command prefixes with `cargo run` ran since *2023-09-12 09:15:30*.\n\n## Settings\nA 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`.\n\n### Light Mode\nTo swap the color scheme for use in a light terminal, set the environment variable `MCFLY_LIGHT`.\n\nbash / zsh:\n```bash\nexport MCFLY_LIGHT=TRUE\n```\n\nfish:\n```bash\nset -gx MCFLY_LIGHT TRUE\n```\n\npowershell:\n```powershell\n$env:MCFLY_LIGHT = \"TRUE\"\n```\n\nTip: on macOS you can use the following snippet for color scheme to be configured based on system-wide settings:\n\nbash / zsh:\n```bash\nif [[ \"$(defaults read -g AppleInterfaceStyle 2\u0026\u003e/dev/null)\" != \"Dark\" ]]; then\n    export MCFLY_LIGHT=TRUE\nfi\n```\n\n### VIM Key Scheme\nBy 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`.\n\nbash / zsh:\n```bash\nexport MCFLY_KEY_SCHEME=vim\n```\n\nfish:\n```bash\nset -gx MCFLY_KEY_SCHEME vim\n```\n\npowershell:\n```powershell\n$env:MCFLY_KEY_SCHEME=\"vim\"\n```\n\n### Fuzzy Searching\nTo 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](https://github.com/cantino/mcfly/issues/183)!\n\nbash / zsh:\n```bash\nexport MCFLY_FUZZY=2\n```\n\nfish:\n```bash\nset -gx MCFLY_FUZZY 2\n```\n\npowershell:\n```powershell\n$env:MCFLY_FUZZY=2\n```\n\n### Results Count\nTo change the maximum number of results shown, set `MCFLY_RESULTS` (default: 30).\n\nbash / zsh:\n```bash\nexport MCFLY_RESULTS=50\n```\n\nfish:\n```bash\nset -gx MCFLY_RESULTS 50\n```\n\npowershell:\n```powershell\n$env:MCFLY_RESULTS=50\n```\n\n### Delete without confirmation\nTo delete without confirmation, set `MCFLY_DELETE_WITHOUT_CONFIRM` to true.\n\nbash / zsh:\n```bash\nexport MCFLY_DELETE_WITHOUT_CONFIRM=true\n```\n\nfish:\n```bash\nset -gx MCFLY_DELETE_WITHOUT_CONFIRM true\n```\n\npowershell:\n```powershell\n$env:MCFLY_DELETE_WITHOUT_CONFIRM=\"true\"\n```\n\n### Interface view\nTo change interface view, set `MCFLY_INTERFACE_VIEW` (default: `TOP`).\nAvailable options: `TOP` and `BOTTOM`\n\nbash / zsh:\n```bash\nexport MCFLY_INTERFACE_VIEW=BOTTOM\n```\n\nfish:\n```bash\nset -gx MCFLY_INTERFACE_VIEW BOTTOM\n```\n\npowershell:\n```powershell\n$env:MCFLY_INTERFACE_VIEW=\"BOTTOM\"\n```\n\n### Disable menu interface\nTo disable the menu interface, set the environment variable `MCFLY_DISABLE_MENU`.\n\nbash / zsh:\n```bash\nexport MCFLY_DISABLE_MENU=TRUE\n```\n\nfish:\n```bash\nset -gx MCFLY_DISABLE_MENU TRUE\n```\n\npowershell:\n```powershell\n$env:MCFLY_DISABLE_MENU=true\n ```\n\n### Results sorting\nTo change the sorting of results shown, set `MCFLY_RESULTS_SORT` (default: RANK).\nPossible values `RANK` and `LAST_RUN`\n\nbash / zsh:\n```bash\nexport MCFLY_RESULTS_SORT=LAST_RUN\n```\n\nfish:\n```bash\nset -gx MCFLY_RESULTS_SORT LAST_RUN\n```\n\npowershell:\n```powershell\n$env:MCFLY_RESULTS_SORT=\"LAST_RUN\"\n ```\n\n### Custom Prompt\nTo change the prompt, set `MCFLY_PROMPT` (default: `$`).\n\nbash / zsh:\n```bash\nexport MCFLY_PROMPT=\"❯\"\n```\n\nfish:\n```bash\nset -gx MCFLY_PROMPT \"❯\"\n```\n\npowershell:\n```powershell\n$env:MCFLY_PROMPT=\"\u003e\"\n ```\n\nNote that only single-character-prompts are allowed. setting `MCFLY_PROMPT` to `\"\u003cstr\u003e\"` will reset it to the default prompt.\n\n### Database Location\n\nMcFly stores its SQLite database in the standard location for the OS. On OS X, this is in `~/Library/Application Support/McFly`, on Linux it is in `$XDG_DATA_DIR/mcfly/history.db` (default would be `~/.local/share/mcfly/history.db`), and on Windows, it is `%LOCALAPPDATA%\\McFly\\data\\history.db`. For legacy support, if `~/.mcfly/` exists, it is used instead.\n\n### Slow startup\n\nIf you have a very large history database and you notice that McFly launches slowly, you can set `MCFLY_HISTORY_LIMIT` to something like 10000 to limit how many records are considered when searching. In this example, McFly would search only the latest 10,000 entries.\n\n### Bash TIOCSTI\n\nStarting with Linux kernel version 6.2, some systems have disabled TIOCSTI (which McFly previously used to write the selected command). McFly works around this issue by using two \"dummy\" keybindings, which default to `ctrl-x 1` and `ctrl-x 2`. If you are using either of these for another purpose, you can set the `MCFLY_BASH_SEARCH_KEYBINDING` and `MCFLY_BASH_ACCEPT_LINE_KEYBINDING`, respectively, to something you are not using. If you would prefer to use the legacy TIOCSTI behavior, you can enable it by setting the `sysctl` variable `dev.tty.legacy_tiocsti` to `1` on your system and set the `MCFLY_BASH_USE_TIOCSTI` bash variable to `1`.\n\n## HISTTIMEFORMAT\n\nMcFly currently doesn't parse or use `HISTTIMEFORMAT`.\n\n## Possible Future Features\n\n* Add a screencast to README.\n* Learn common command options and autocomplete them in the suggestion UI?\n* Sort command line args when coming up with the template matching string.\n* Possible prioritization improvements:\n   * Cross validation \u0026 explicit training set selection.\n   * Learn command embeddings\n\n## Development\n\n### Contributing\n\nContributions and bug fixes are encouraged! However, we may not merge PRs that increase complexity significantly beyond what is already required to maintain the project. If you're in doubt, feel free to open an issue and ask.\n\n### Running tests\n\n`cargo test`\n\n### Releasing (notes for @cantino)\n\n1. Edit `Cargo.toml` and bump the version.\n1. Edit CHANGELOG.txt\n1. Run `cargo clippy` and `cargo fmt`.\n1. Recompile (`cargo build`) and test (`cargo test`)\n1. `git add -p`\n1. `git ci -m 'Bumping to vx.x.x'`\n1. `git tag vx.x.x`\n1. `git push origin head --tags`\n1. Let the build finish.\n1. Edit the new Release on Github.\n1. `cargo publish`\n1. TBD: update homebrew-core Formula at https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mcfly.rb\n\nOld:\n1. Edit `pkg/brew/mcfly.rb` and update the version and SHAs. (`shasum -a 256 ...`)\n1. Edit `../homebrew-mcfly/pkg/brew/mcfly.rb` too.\n  1. `cp pkg/brew/mcfly.rb ../homebrew-mcfly/pkg/brew/mcfly.rb`\n  1. Compare with `diff ../homebrew-mcfly/pkg/brew/mcfly.rb ../mcfly/pkg/brew/mcfly.rb ; diff ../homebrew-mcfly/HomebrewFormula/mcfly.rb ../mcfly/HomebrewFormula/mcfly.rb`\n1. `git add -p \u0026\u0026 git ci -m 'Update homebrew' \u0026\u0026 git push`\n1. `cd ../homebrew-mcfly \u0026\u0026 git add -p \u0026\u0026 git ci -m 'Update homebrew' \u0026\u0026 git push \u0026\u0026 cd ../mcfly`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcantino%2Fmcfly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcantino%2Fmcfly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcantino%2Fmcfly/lists"}