prmt 🚀
Ultra-fast, customizable shell prompt generator written in Rust. Features zero-copy parsing with SIMD optimizations for sub-microsecond template processing.
Features
- ⚡ Blazing Fast: Instant prompt rendering that won't slow down your terminal
- 🎨 Highly Customizable: Full control over colors, formats, and what information to show
- 📦 Zero-Copy Parsing: Efficient memory usage for minimal overhead
- 🦀 Memory Efficient: Written in Rust for maximum performance
- 🚀 Context Aware: Automatically detects and shows relevant project information
- ✨ Smart Rendering: Only shows information when it's relevant to your current directory
Performance
Actual Response Times
| Scenario | Time | Notes |
|---|---|---|
| Path only | ~0.01ms | Minimal prompt |
| Path + Git | ~1-2ms | Branch and status |
| With Rust version | ~25-30ms | Includes rustc --version |
With --no-version |
<5ms | Skips all version detection |
Installation
# Install from crates.io
# Build from source (Rust 2024 edition required)
# Or install directly
# Verify installation
Format Specification
Format Syntax
{module} - Default everything
{module:style} - Custom style
{module:style:type} - Custom style and type
{module:style:type:prefix} - Add prefix to value
{module:style:type:prefix:postfix} - Add prefix and postfix
# Omitting parts (empty means default)
{module::::suffix} - Default style/type, suffix only
{module:::prefix:} - Default style/type, prefix only
{module:::prefix:suffix} - Default style/type, both prefix/suffix
{module::type} - No style, specific type
{module::type::suffix} - No style, specific type, suffix only
Available Modules
| Module | Detection | Description |
|---|---|---|
path |
Always active | Current directory with ~ for home |
ok |
Exit code = 0 | Shows when last command succeeded (default: ❯) |
fail |
Exit code ≠ 0 | Shows when last command failed (default: ❯) |
git |
.git directory |
Branch name with status indicators |
node |
package.json |
Node.js version |
python |
requirements.txt, pyproject.toml, etc |
Python version |
rust |
Cargo.toml |
Rust version |
deno |
deno.json, deno.jsonc |
Deno version |
bun |
bun.lockb |
Bun version |
go |
go.mod |
Go version |
time |
Always active | Current time in various formats |
Type Values
Version modules (rust, node, python, etc.):
fullorf- Full version (1.89.0)shortors- Major.minor (1.89)majororm- Major only (1)
Path module:
relativeorr- Path with ~ for home directory (default)absoluteora- Full absolute path without ~ substitutionshortors- Last directory only
Git module:
fullorf- Branch with status (default)shortors- Branch name only
Ok/Fail modules:
full- Default symbol (❯)code- Shows the actual exit code number- Any other string - Uses that string as the symbol (e.g.,
{ok::✓}shows ✓)
Time module:
24h- 24-hour format HH:MM (default)24hsor24HS- 24-hour format with seconds HH:MM:SS12hor12H- 12-hour format hh:MMAM/PM12hsor12HS- 12-hour format with seconds hh:MM:SSAM/PM
Type Validation
The format parser validates types at parse time to catch errors early:
# Valid types for each module
# Invalid types produce clear errors
# Error: Invalid type 'major' for module 'path'. Valid types: relative, r, absolute, a, short, s
# Error: Invalid type 'major' for module 'git'. Valid types: full, short
Default Module Styles
| Module | Default Color | Can Override |
|---|---|---|
path |
cyan | Yes |
ok |
green | Yes |
fail |
red | Yes |
git |
purple | Yes |
node |
green | Yes |
rust |
red | Yes |
python |
yellow | Yes |
go |
cyan | Yes |
deno |
- | Yes |
bun |
- | Yes |
time |
- | Yes |
Styles
Colors: black, red, green, yellow, blue, purple, cyan, white, #hexcode
Modifiers: bold, dim, italic, underline, reverse, strikethrough
Combine with dots: cyan.bold, red.dim.italic
Escaping
\{→{(literal brace)\}→}(literal brace)\n→ newline\t→ tab\:→:(literal colon in fields)\\→\(literal backslash)
Usage Examples
# Simple format with defaults
# Output: ~/projects 1.89.0 master
# Format with types and styles
# Simplified formats with omitted parts
# Add your own icons with prefix
# Using short format aliases
# No style with type
# With exit code indicators (requires --code flag)
# Output (success): ~/projects ❯ (green)
# Output (failure): ~/projects ❯ (red)
# Fast mode (no version detection)
# Output: ~/projects (only shows active modules, no versions)
# Custom symbols for ok/fail using type as symbol
# Output (success): ~/projects ✓
# Output (failure): ~/projects ✗
# Show exit code on failure
# Output (success): ~/projects ❯
# Output (failure with code 127): ~/projects 127
# Time formats
Shell Integration
Bash
# Add to ~/.bashrc
PS1='$(prmt --code $? "{path:cyan:s} {git:purple:s:on :} {ok:green}{fail:red}")\$ '
# Or set via environment variable
PS1='$(prmt --code $?)\$ '
Bash with Transient Prompt
For a cleaner command history, you can set up a transient prompt that shows a simplified prompt after command execution:
# Add to ~/.bashrc or ~/.init_bash
# Helper functions for transient prompt
# Main prompt with full information
PS1='$(prmt --code $? "{path:#89dceb}{node:#a6e3a1:f: [:]}{rust:#f38ba8:f: 🦀}{git:#f9e2af:f: }\n{ok:#a6e3a1}{fail:#f38ba8} ")'
# Transient prompt configuration
PS0='\[$(deleteprompt)\]$(prompt_indicator ${LAST_EXIT_CODE}) $(lastcommand)\n\[${PS1:0:$((EXPS0=1,0))}\]'
PROMPT_COMMAND='LAST_EXIT_CODE=$?; echo -ne "\033]0;${PWD##*/}\007"; [ "$EXPS0" = 0 ] && deleteprompt && echo -e "$(prompt_indicator ${LAST_EXIT_CODE})" || EXPS0=0'
This configuration:
- Shows a full prompt with path, version info, and git status before commands
- After execution, replaces it with a minimal prompt showing just the colored success/fail indicator and the command
- Maintains colored indicators (green ❯ for success, red ❯ for failure) in the transient prompt
- Handles edge cases like Ctrl+C and empty Enter presses correctly
Zsh
# Add to ~/.zshrc
PROMPT='$(prmt --code $? "{path:cyan:s} {git:purple:s:on :} {ok:green}{fail:red}") '
# Or with environment variable
PROMPT='$(prmt --code $?) '
Fish
# Add to ~/.config/fish/config.fish
function fish_prompt
prmt --code $status '{path:cyan:s} {git:purple:s:on :} {ok:green}{fail:red} '
end
# Or with environment variable
set -x PRMT_FORMAT "{path:cyan:r} {python:yellow:m:🐍 :} {git:purple}"
function fish_prompt
prmt --code $status
end
PowerShell
# Add to $PROFILE
function prompt {
prmt --code $LASTEXITCODE '{path:cyan:s} {git:purple:s:on :} {ok:green}{fail:red} '
}
# Or with environment variable
$env:PRMT_FORMAT = "{path:cyan:r} {git:purple}"
function prompt {
prmt --code $LASTEXITCODE
}
Command-Line Options
prmt [OPTIONS] [FORMAT]
OPTIONS:
-n, --no-version Skip version detection for speed
-d, --debug Show debug information and timing
-b, --bench Run benchmark (100 iterations)
--code <CODE> Exit code of the last command (for ok/fail modules)
--no-color Disable colored output
-h, --help Print help
-V, --version Print version
ARGS:
<FORMAT> Format string (default from PRMT_FORMAT env var)
Building from Source
# Requirements: Rust 2024 edition
# Run tests
# Benchmark
License
MIT