Giter VIP home page Giter VIP logo

mcfly's Introduction

Build Status

McFly - fly through your shell history

screenshot

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.

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 OS X or Linux)

  1. Install the tap:

    brew tap cantino/mcfly
  2. Install mcfly:

    brew install mcfly
  3. Add the following to the end of your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file, as appropriate, changing /usr/local to your brew --prefix if needed:

    Bash:

    eval "$(mcfly init bash)"

    Zsh:

    eval "$(mcfly init zsh)"

    Fish:

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

Uninstalling with Homebrew

  1. Remove mcfly:
    brew uninstall mcfly
  2. Remove the tap:
    brew untap cantino/mcfly
  3. Remove the lines you added to ~/.bashrc / ~/.zshrc / ~/.config/fish/config.fish.

Install with MacPorts (on OS X)

  1. Update the ports tree

    sudo port selfupdate
  2. Install mcfly:

    sudo port install mcfly
  3. Add 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 | source
  4. Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.

Uninstalling with MacPorts

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

Installing using our install script

  1. curl -LSfs https://raw.githubusercontent.com/cantino/mcfly/master/ci/install.sh | sh -s -- --git cantino/mcfly

  2. 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 | source
  3. Run . ~/.bashrc / . ~/.zshrc / source ~/.config/fish/config.fish or restart your terminal emulator.

Installing manually from GitHub

  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 file, respectively:

    Bash:

    eval "$(mcfly init bash)"

    Zsh:

    eval "$(mcfly init zsh)"

    Fish:

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

Install manually from source

  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, or ~/.config/fish/config.fish file, respectively:

    Bash:

    eval "$(mcfly init bash)"

    Zsh:

    eval "$(mcfly init zsh)"

    Fish:

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

iTerm2

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

iterm2 UI instructions

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.

Light Mode

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

bash / zsh:

export MCFLY_LIGHT=TRUE

fish:

set -gx MCFLY_LIGHT TRUE

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:

export MCFLY_KEY_SCHEME=vim

fish:

set -gx MCFLY_KEY_SCHEME vim

Fuzzy Searching

To enable fuzzy searching, set MCFLY_FUZZY.

bash / zsh:

export MCFLY_FUZZY=true

fish:

set -gx MCFLY_FUZZY true

Results Count

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

bash / zsh:

export MCFLY_RESULTS=50

fish:

set -gx MCFLY_RESULTS 50

Interface view

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

bash / zsh:

export MCFLY_INTERFACE_VIEW=BOTTOM

fish:

set -gx MCFLY_INTERFACE_VIEW BOTTOM

Results sorting

To 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_RUN

fish:

set -gx MCFLY_RESULTS_SORT LAST_RUN

Slow startup

If 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.

Possible Future Features

  • Add a screencast to README.
  • Learn common command options and autocomplete them in the suggestion UI?
  • Sort command line args when coming up with the template matching string.
  • Possible prioritization improvements:
    • Cross validation & explicit training set selection.
    • Learn command embeddings

Development

Running tests

cargo test

Releasing (notes for @cantino)

  1. Edit Cargo.toml and bump the version.
  2. Edit CHANGELOG.txt
  3. Recompile (cargo build).
  4. git add -p
  5. git ci -m 'Bumping to vx.x.x'
  6. git tag vx.x.x
  7. git push origin head --tags
  8. Let the build finish.
  9. Edit the new Release on Github.
  10. Edit pkg/brew/mcfly.rb and update the version and SHAs. (shasum -a 256 ...)
  11. Edit ../homebrew-mcfly/pkg/brew/mcfly.rb too.
  12. cp pkg/brew/mcfly.rb ../homebrew-mcfly/pkg/brew/mcfly.rb
  13. Compare with diff ../homebrew-mcfly/pkg/brew/mcfly.rb ../mcfly/pkg/brew/mcfly.rb ; diff ../homebrew-mcfly/HomebrewFormula/mcfly.rb ../mcfly/HomebrewFormula/mcfly.rb
  14. git add -p && git ci -m 'Update homebrew' && git push
  15. cd ../homebrew-mcfly && git add -p && git ci -m 'Update homebrew' && git push && cd ../mcfly
  16. cargo publish

mcfly's People

Contributors

agrism avatar akinnane avatar b3nj5m1n avatar bperel avatar camerondavison avatar cantino avatar dmfay avatar domoritz avatar f355 avatar federicotdn avatar freamon avatar goddade avatar greyblake avatar gwk avatar herbygillot avatar imgbotapp avatar jamjar00 avatar konfekt avatar markusjevringgoeuro avatar marshall avatar melkor333 avatar praveenperera avatar rbutoi avatar safarimonkey avatar scooter-dangle avatar supersandro2000 avatar teeparham avatar tjkirch avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.