Joseph M OBrien joe
  • Joined on 2026-03-15

prefixe (0.4.0)

Published 2026-05-31 14:31:29 -05:00 by joe

Installation

[registry]
default = "gitea"

[registries.gitea]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add prefixe@0.4.0

About this package

Prepend validated prefixes to shell commands — reads rx prefix config

prefixe

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.

What it does

  • Reads a TOML prefix config (~/.config/rx/prefixes.toml by 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 PrefixStore and ProbeStore traits for easy testing and substitution

Usage

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 format

~/.config/rx/prefixes.toml:

[mappings]
gh = ["op", "plugin", "run", "--"]
"cargo test" = ["dotenvx", "run", "--"]

[[candidate_prefixes]]
candidate_prefixes = [["op", "run", "--"]]

learn_on_successful_fallback = true

Environment variables

Variable Default Purpose
CRS_RX_PREFIXES $XDG_CONFIG_HOME/rx/prefixes.toml Override prefix config path
CRS_CTX_DIR .ctx Directory for probe state

Documentation

License

MIT OR Apache-2.0

Dependencies

ID Version
glob ^0.3
serde ^1
shell-words ^1
thiserror ^1
toml ^0.8
proptest ^1
tempfile ^3

Keywords

prefix shell command rx wrapper
Details
Cargo
2026-05-31 14:31:29 -05:00
1
MIT OR Apache-2.0
21 KiB
Assets (1)
Versions (1) View all
0.4.0 2026-05-31