English | 日本語
runex is a cross-shell tool that expands short inputs (runes) into full commands (casts) as the user types.
- Input: short token (e.g.
gcm) - Output: expanded command (e.g.
git commit -m)
The core concept is "rune-to-cast expansion".
Compress long incantations into runes, then expand them at execution time.
- Rune: a short input token
- Cast: the full command to be executed
- runex: the Rune → Cast expansion engine
- Typing long commands is tedious
- Aliases and functions are scattered across shells
- Settings cannot be unified across pwsh / bash / nu
- No fish-abbr-like UX in other shells
- Cross-shell shared abbreviation definitions
- Real-time expansion on a configurable trigger key
- Conditional expansion (
when_command_exists) for graceful multi-machine fallback - Centralized management via a single
config.toml - Debuggability:
which --whyandexpand --dry-runexplain every expansion decision
- bash
- zsh
- PowerShell (pwsh)
- cmd (via Clink)
- Nushell (nu)
config.toml
↓
runex (single Rust crate, internal modules: domain / app / infra)
↓
shell adapters
├─ pwsh (PSReadLine)
├─ bash (readline / bind)
├─ zsh (zle / bindkey)
├─ clink (Lua)
└─ nu (script)
Internal layering since 0.1.14:
domain/— pure logic (model, expand, hook, sanitize, timings, shell quoting + templates). No I/O, no env reads.app/— orchestration / parse / validate / generate (config, doctor, init, shell_export, hook).infra/— file / registry / env access (env withHomeDirResolver, integration_cache, integration_check).cmd/— CLI subcommand handlers (one file perCommandsenum variant).util/— leaf helpers (shell detection, command_exists factory, prompt).
Dependency direction: cmd → app → domain, cmd → util/infra,
infra → domain (one-way, no cycles). Pre-0.1.14 the same code
lived in two crates (runex-core + runex); the split was
removed in Phase C because the internal pub boundary it carried
served no external consumer.
Each shell adapter is a thin template that reads the live buffer,
calls runex hook, and applies the returned eval text. Every
per-keystroke decision is made in Rust. The adapter is installed
as a static cache file, and clink and PowerShell send the buffer
hex-encoded; design.md gives the reasons for both.
- Token → expansion (first passing rule wins)
- Self-loop guard:
key == expand→ skip rule, continue evaluation when_command_exists: skip rule if any listed command does not resolve viawhichat hook time; continue evaluation- Fallback: pass through undefined tokens unchanged
- Multiple rules with the same key: evaluated in order as a fallback chain
runex expand --token <token> expand a token
runex expand --token <token> --dry-run simulate expansion, show match trace
runex list list all abbreviations
runex list <key> show only the rule whose key matches exactly
runex which <token> show which rule matches
runex which <token> --why show full match trace with skip reasons
runex doctor check config and environment
runex doctor --no-shell-aliases skip alias conflict checks (avoids spawning shells)
runex doctor --strict also warn about unknown config fields
runex doctor --verbose show full error details
runex add <key> <expand> add an abbreviation rule to config
runex add <key> <expand> --when <cmd> add with when_command_exists condition
runex remove <key> remove an abbreviation rule from config
runex init create config and install shell integration (auto-detect shell)
runex init <shell> target a specific shell (bash/zsh/pwsh/clink/nu)
runex init -y same, skip confirmation prompts
runex export <shell> print the shell integration script
runex export <shell> --bin <name> use a custom binary name or path in the script
runex timings <key> show per-phase timing breakdown of expand
runex timings time all abbreviation rules
runex config where print the resolved config file path
runex config type print the config file contents to stdout
runex config show open the config file with the OS-associated app
runex config reload regenerate the installed shell integration caches from the config file
runex version show version and build commit
Global flags (accepted by every subcommand):
--config <path> override config file path (overrides RUNEX_CONFIG)
--path-prepend <dir> prepend directory to PATH for command existence checks
--json JSON output (supported by: list, doctor, version, expand, which, timings, config where)
runex hook and runex paste-clipboard are hidden subcommands called by the shell integration, not by users.
Default: $XDG_CONFIG_HOME/runex/config.toml, falling back to ~/.config/runex/config.toml on all platforms.
Override: RUNEX_CONFIG env var or --config flag.
version = 1
[keybind.trigger]
default = "space" # default trigger for all shells
bash = "alt-space" # shell-specific override (optional)
[[abbr]]
key = "ls"
expand = "lsd"
when_command_exists = ["lsd"]
[[abbr]]
key = "ls"
expand = "ls --color=auto"
[[abbr]]
key = "gcm"
expand = "git commit -m"See docs/config-reference.md for the full field reference.
- Fast: the in-process expansion path (config load, shell resolve,
expand) completes in under 1 ms per key press.
runex timings <key> --jsonis the instrument. Measured on 2026-09-16 with a release build of 0.1.20 (b549c9c) on Windows 11 against a one-rule config: 10 runs, total 205–345 µs, median 217 µs. Process spawn and the shell's own key handling are outside this figure. - Cross-platform: Windows / Linux / macOS
- Shell-independent core logic (
runex/src/domain/modules) - Safe: self-loop guard prevents infinite expansion
- Testable:
command_existsinjected via dependency injection
- No full shell parser — token-level processing only
- Quoted strings inside tokens are not interpreted
- runex does not re-escape expansion text; the shell receives it as-is
- Per-keystroke logic centralised in the
runex hooksubcommand; shell templates reduced to thin wrappers. - Static integration cache for bash / zsh / pwsh / nu, sourced from
the rc file by absolute path.
runex config reloadregenerates it after a hand edit. runex doctorreports environment-level health: Windowseffective_search_pathbreakdown,integration:<shell>rc file marker check,integration:<shell>:cacheheader check, and clink lua drift detection.runex init <shell>accepts a shell positional and writes the clink lua integration directly. The seed config includes a working sample (gst → git status). Per-shell "Next steps" guidance after init.- crates.io publish moved into CI via OIDC Trusted Publishing — no
long-lived
CARGO_REGISTRY_TOKENanywhere. Test gate added so a tag push can never ship binaries from a commit whose tests didn't finish. - Containerized Linux CI with a digest-pinned image.
- Distribution: GitHub Releases for six targets, crates.io, AUR
(
runex-binandrunex), Homebrew tap, winget,mise github:. - clink sends the buffer hex-encoded, so
",%and!in the buffer no longer break expansion. - PTY-driven keystroke tests for bash, zsh, pwsh and nu
(
runex/tests/*_pty_integration.rs), plus rc-file-write property tests forrunex init(runex/tests/cli_integration.rs). docs/recipes.mdcookbook with use-case-drivenconfig.tomlsnippets.
- Continue refining diagnostics surfaced by
doctorandinitas new failure modes are observed in the wild. - A clink keystroke test. Today's clink coverage runs the template's
cmd.exe command line through a real cmd.exe
(
runex/tests/cli_integration.rs) but does not drive clink itself.
- Fuzzy suggestions / fallback matching
- Interactive picker
- History-based learning
- IDE integration (Neovim, VS Code)
cargo-binstallmetadata inCargo.toml
- All shells unified under a single config file
- Perceived reduction in typing time
- Reduction in per-shell alias sprawl
runex =
- run (execute)
- ex (expand / execute)
- rune (compressed command)
runex is a rune-to-cast expansion engine.