Prepend validated prefixes to shell commands, with support for confirmed mappings and speculative candidate learning.
Designed as the core library for coursers /
rx prefix config integration.
- Reads a TOML prefix config (
~/.config/rx/prefixes.tomlby default) - Rewrites shell command strings by prepending a known prefix to each segment
- Supports compound commands split on
&&,||,;,| - Tracks speculative "candidate" probes for learning new mappings on success
- Exposes
PrefixStoreandProbeStoretraits for easy testing and substitution
use prefixe::{FilePrefixStore, PrefixStore, rewrite_command};
let store = FilePrefixStore { path: FilePrefixStore::default_path() };
let config = store.load();
let result = rewrite_command("gh issue list && gh pr list", &config);
println!("{}", result.rewritten);
// → "op plugin run -- gh issue list && op plugin run -- gh pr list"~/.config/rx/prefixes.toml:
[mappings]
gh = ["op", "plugin", "run", "--"]
"cargo test" = ["dotenvx", "run", "--"]
[[candidate_prefixes]]
candidate_prefixes = [["op", "run", "--"]]
learn_on_successful_fallback = true| Variable | Default | Purpose |
|---|---|---|
CRS_RX_PREFIXES |
$XDG_CONFIG_HOME/rx/prefixes.toml |
Override prefix config path |
CRS_CTX_DIR |
.ctx |
Directory for probe state |
- API docs (docs.rs)
- Book — mdBook scaffold in
docs/book/
MIT OR Apache-2.0