I was tired of 50ms+ shell latency, so I built a sub-millisecond prompt in Rust (prmt)

358 points 3axap4eHko 111 comments

Hey /r/rust,

Like many of you, I live in my terminal. I was using Starship for a while, and while it's a fantastic project, I couldn't shake the feeling of latency. A 10-50ms delay for every single prompt (and even worse over SSH) felt like a constant papercut.

I wanted a prompt that felt truly instant. My goal was to get rendering down to the sub-millisecond range, and to do it with predictable performance (i.e., no async runtime).

So, I built prmt: an ultra-fast, customizable shell prompt generator written in Rust.

GitHub Repo: https://github.com/3axap4eHko/prmt

Crates.io: https://crates.io/crates/prmt

Why is it so fast?

This is where Rust shines. The core design philosophy was to do as little as possible and be as efficient as possible.

Zero-Copy Parsing: The prompt format string is parsed with minimal to no allocations.

SIMD Optimizations: String processing is heavily optimized.

No Async Runtime: This is a key feature. prmt doesn't use Tokio or any async runtime. This means no scheduler overhead and, more importantly, predictable latency. Your prompt will never be slow because an async task is being polled.

Single Binary, Zero Dependencies: It's a single, tiny binary. Just cargo install prmt and you're good to go.

The Benchmarks

This is what I was aiming for. The renderer itself is in the microseconds. The only thing that takes time is checking for things like git status or project versions (rustc --version).

Here's a comparison against the most popular prompts:

Prompt Tool Typical Render Time What's Slow?
prmt (Typical) ~1-2 ms Git status check
prmt (Fast mode) < 5 ms Skips all version calls
prmt (Minimal) ~10 µs (Nothing)
starship ~10-50 ms Async runtime, version detection
oh-my-posh ~20-100 ms Heavier binary, version detection

Even in a "full" setup (path, git, rust version, node version), prmt clocks in around 25-30ms, and that's only because it's shelling out to rustc --version. If you don't need versions, the --no-version flag keeps it under 5ms.

Try it yourself

If you're also chasing that "instant" feeling, you can install it easily:

cargo install prmt

Then just add it to your shell's config.

Bash (~/.bashrc):

PS1='$(prmt --code $? "{path:cyan:s} {git:purple:s:on :} {ok:green}{fail:red} ")'

Zsh (~/.zshrc):

# Add this line first
setopt PROMPT_SUBST

# Add the prompt
PROMPT='$(prmt --code $? "{path:cyan:s} {git:purple:s:on :} {ok:green}{fail:red} ")'

It's fully customizable, but it works great out of the box. The README has the full format cheatsheet.

I built this to solve my own problem, but I'm hoping others find it useful too. I'd love to get feedback from the Rust community on the code, performance, or any features you think are missing!