Integrate McFly with fzf to combine a solid command history database with a widely-loved fuzzy search UI
Features:
- Advanced history tracking and prioritization courtesy of McFly
- Rebinds
ctrl-r
to use an fzf-based interface- Supports fzf search syntax
- Inline layout options
- Toggle options in fzf interface:
- F1: Sort by time / neural network score
- F2: Limit to commands run from current directory / any directory
- F3: Filter by exit status: [Okay (zero) / Fail (non-zero) / Any]
-
Install mcfly: Included with the mcfly-fzf binaries. Alternatively download mcfly release binary, or view other installation options
-
Install fzf: Download binary, or view other installation options
-
Install mcfly-fzf: Download binary
Alternatively, install from source:cargo install --git https://github.com/bnprks/mcfly-fzf
-
Make sure that
mcfly
,fzf
, andmcfly-fzf
are all added to your$PATH
. Following instructions from McFly:For example, you could create a directory at
~/bin
, copymcfly
to this location, and addexport PATH="$PATH:$HOME/bin"
to your.bashrc
/.zshrc
, or runset -Ua fish_user_paths "$HOME/bin"
for fish. -
Add the following to the end of your
~/.bashrc
,~/.zshrc
, or~/.config/fish/config.fish
file:Bash:
eval "$(mcfly init bash)" eval "$(mcfly-fzf init bash)"
Zsh:
eval "$(mcfly init zsh)" eval "$(mcfly-fzf init zsh)"
Fish:
mcfly init fish | source mcfly-fzf init fish | source
- Press
ctrl-r
to open search:- Type to search
- Arrow keys to navigate up/down
- Enter to select
- F1/F2/F3 to adjust view settings
- Respects the following environment variables
MCFLY_HISTORY_LIMIT
MCFLY_RESULTS_SORT
FZF_DEFAULT_OPTS
,FZF_CTRL_R_OPTS
(can include multiple options fromman fzf
)MCFLY_FZF_NO_STRICT_ORDERING
: if set, this variable causes mcfly-fzf to default to strict ordering off rather than on for new terminal sessions.
- To delete history entries, run
mcfly search
manually
Overall:
mcfly-fzf
imports themcfly
crate to access the database.- A per-session temporary json file stores the search setting toggles within and between searches.
What happens during ctrl-r
:
mcfly-fzf dump
reads the mcfly sqlite database and prints the entry to stdout, where it is piped tofzf
- Toggling F1/F2/F3 in
fzf
runsmcfly-fzf toggle
, which updates a temporary json file stored at$MCFLY_FZF_OPTS
. Thenmcfly-fzf dump
runs again to re-populate the filtered results forfzf
. - After selecting a history item,
mcfly-fzf select
marks the item in theselected_commands
table so that the McFly neural network can prioritize frequently-selected items.