fzfx

asciicast

fzfx is an offline, fast, and semantic CLI command finder designed to instantly discover previously executed terminal commands using vector search rather than rigid exact or fuzzy substring matching.

GitHub Crates.io


Features


Installation

Quick Install (Shell Script)

sh
curl -fsSL https://raw.githubusercontent.com/aether-flux/fzfx/main/install.sh | sh

cargo Install

sh
cargo install fzfx

Manual Build

sh
# Clone the repo
git clone https://github.com/aether-flux/fzfx
cd fzfx

# Run the CLI
cargo run    # with additional flags and arguments

Usage

Pipe any command list or history file into fzfx:

sh
# Search through bash history
cat ~/.bash_history | fzfx -q "check disk space"

# Search through your terminal's history
history | fzfx -q "list disk partitions"

# Search active process list
ps aux | fzfx -q "kill web server"

If no query (-q or --query) is supplied, fzfx prompts for input interactively:

sh
fzfx -f ~/.bash_history

Flags and Options

FlagLong FlagDescription
-q--query <TEXT>Initial search query
-f--data-file <PATH>Path to candidate file (one entry per line)
-x--execAutomatically execute selected command
-c--copyCopy selected command to clipboard
-r--rawPrint top match only (non-interactive, for scripts/AI agents)
-k--top-k <NUM>Specify number of results to show (default = 10)
-C--clear-cacheRemove cache files for command embedding
NA--clear-allRemove both model and embedding cache files

Examples

Search and Copy Command

sh
fzfx -f ~/.bash_history -q "list docker containers" -c

Search and Execute Immediately

sh
history | fzfx -q "find large files" -x

Non-Interactive Script Integration

sh
CMD=$(fzfx -f commands.txt -q "restart nginx" -r)
eval "$CMD"

Clear all cache files

sh
fzfx --clear-all

Shell Integration

Add a convenient shortcut to your ~/.zshrc or ~/.bashrc to invoke fzfx directly over your command history:

sh
fz() {
    local cmd
    cmd=$(cat ~/.bash_history | fzfx -q "$*" -c)
}

Benchmarks

fzfx is benchmarked using Criterion.rs across multiple execution paths to evaluate model cold starts, embedding latencies, and persistent cache hit speeds.

Execution StateLatencyDescription
Fully Cold~10.3sInitial runtime setup, model weight loading, and initial downloads.
Warm model, Cold cache~36.1msModel cached on-disk, batch computing ~10 missing embeddings via fastembed.
Warm model, Warm cache~729.5nsInstant lookup hit against cached embeddings serialized into hashmap (ahash).
Hybrid Rerank only~2.5µsCombined fuzzy distance search and cosine vector similarity to calculate final score.

NOTE

Note on Cold Starts: Benchmark 01 reflects isolated test runs that re-instantiate the ONNX environment on every iteration. In real-world CLI usage, warm-cache lookups execute sub-millisecond (< 1 µs), making fzfx feel instant in the terminal.


Cache and Storage

fzfx respects standard OS cache paths:

Model weights are cached under their specific directories and precomputed line vectors are serialized into embeddings.bin. To reset your search index cache, simply delete embeddings.bin.

Communicate

Find me on
Mail me atamartya96@proton.me
Pokeball vector art