# prmt ๐Ÿš€ > Ultra-fast, customizable shell prompt that won't slow you down [![Crates.io](https://img.shields.io/crates/v/prmt.svg)](https://crates.io/crates/prmt) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Rust](https://img.shields.io/badge/rust-2024-orange.svg)](https://www.rust-lang.org) ![Terminal](./terminal.png) > Rendered with `"{path:#89dceb}{rust:#f38ba8:f: ๐Ÿฆ€}{git:#f9e2af:f: }\n{ok:#a6e3a1}{fail:#f38ba8} "` ## Features - **โšก Blazing Fast**: Sub-millisecond rendering for typical prompts (~2ms end-to-end) - **๐ŸŽจ Highly Customizable**: Full control over colors, formats, and what information to show - **๐Ÿš€ Context Aware**: Automatically detects git repos, project files, shows only what's relevant - **๐Ÿ“ฆ Zero Dependencies**: Single binary, no runtime dependencies required - **๐Ÿฆ€ Memory Efficient**: Zero-copy parsing with SIMD optimizations - **โœจ Smart Rendering**: Only shows information when relevant to your current directory ## Why prmt? **Faster than alternatives** โ€“ Typical prompts render in ~2ms. Starship averages 10-50ms, oh-my-posh 20-100ms. **Zero configuration needed** โ€“ Works out of the box with sensible defaults. Customize only what you want. **Predictable performance** โ€“ No async operations, no network calls, no surprises. Your prompt is always instant. **Single binary** โ€“ Just install and go. No configuration files required unless you want them. **Context-aware** โ€“ Automatically detects git repositories, Rust/Node/Python projects, and shows only relevant info. ## Quick Start **1. Install** **2. Add to your shell** (pick one) **Bash** โ€“ Add to `~/.bashrc`: **Zsh** โ€“ Add to `~/.zshrc` (auto-detected by default; `--shell zsh` forces wrapping): **Fish** โ€“ Add to `~/.config/fish/config.fish`: **3. Reload your shell** Done! ๐ŸŽ‰
Advanced setup (PROMPT_COMMAND, precmd, environment variables) ### Bash with PROMPT_COMMAND *If you already use `PROMPT_COMMAND`, append `_prmt_prompt` instead of overwriting it.* ### Bash transient prompt (no ble.sh) This replaces the full prompt with a compact one after the command runs. It relies on `tput` and Bash 4.4+. ### Zsh with precmd ### PowerShell ### Environment Variable All shells support using `PRMT_FORMAT` environment variable:
## Popular Prompts **Minimal** **Identity (via env module)** **Compact with time** **Full featured with newline** **Status-focused** **With exit codes** ## Installation ## Usage Examples ## Format Specification ### Format Syntax Each module may appear once per template. The parameterized `env` and `json` modules may appear multiple times because each occurrence can request a different value. ### 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.lock`, `bun.lockb` | Bun version | | `go` | `go.mod` | Go version | | `elixir` | `mix.exs` | Elixir version | | `env` | Requested variable is set/non-empty | Value of a specific environment variable (format = name) | | `time` | Always active | Current time in various formats | | `json` | `--stdin` flag | Extract values from JSON piped via stdin (format = dot-path) | ### Type Values **Version modules** (rust, node, python, etc.): - `full` or `f` - Full version (1.89.0) - `short` or `s` - Major.minor (1.89) - `major` or `m` - Major only (1) **Path module**: - `relative` or `r` - Path with ~ for home directory (default) - `git` - Path from the Git repository directory, falling back to `relative` outside a repository - `absolute`, `a`, or `f` - Full absolute path without ~ substitution - `initials` or `i` - Parent segments shortened to their first character; last segment kept full (hidden dirs keep the leading `.`) - `unvowel` or `u` - Interior vowels stripped from each segment; first character kept; segments โ‰ค 3 chars unchanged - `short` or `s` - Last directory only **Git module**: - `full` or `f` - Branch with status (default) - `short` or `s` - Branch name only - Add `+owned` (or `+o`) to show only repos owned by the current user (e.g., `{git::full+owned}`) **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) - `24hs` or `24HS` - 24-hour format with seconds HH:MM:SS - `12h` or `12H` - 12-hour format hh:MMAM/PM - `12hs` or `12HS` - 12-hour format with seconds hh:MM:SSAM/PM **Env module**: - The `type` field is required and must be the environment variable name (e.g., `{env::USER}` or `{env:blue:PATH}`). - The module emits the variable value only when it exists and is non-empty; otherwise it returns nothing so the placeholder is effectively inactive. - Example for identity: `{env::USER}@{env::HOSTNAME}` **Json module** (requires `--stdin`): - Reads JSON from stdin and extracts values using dot-path notation. - The `type` field is the dot-path to the value (e.g., `{json::.model.id}` or `{json::name}`). - Supports nested objects (`{json::.a.b.c}`), array indexing (`{json::.items.0}`), and the leading dot is optional. - Strings are returned as-is, numbers and booleans are stringified, null and missing paths produce no output. - When `--stdin` is not passed, json placeholders are silently inactive. **Claude Code status line** -- pipe JSON context to prmt to display model and context window usage. Add to your Claude Code `settings.json`: ### Type Validation The format parser validates types at parse time to catch errors early: ### 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` **Background colors**: use `fg+bg` or `+bg` (background only), then modifiers. Examples: `#ffffff+#333333`, `+blue`, `cyan+#222.dim` ### Escaping - `\{` โ†’ `{` (literal brace) - `\}` โ†’ `}` (literal brace) - `\n` โ†’ newline - `\t` โ†’ tab - `\:` โ†’ `:` (literal colon in fields) - `\\` โ†’ `\` (literal backslash) ## 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 | ### Benchmark Snapshot | Scenario | Time (ยตs) | Notes | |----------|-----------|-------| | Minimal render | 1.57 | `{path}` only | | Typical prompt | 2,820.45 | `{path} {git} {ok}` | | Full prompt with versions | 8,617.75 | `{path} {rust} {node} {git}` | | In-process execute (typical) | 2,820.93 | Library `execute` call | > Measurements captured on an Intel Core i9-13900K host with project files on a SATA SSD (Rust 1.96.0 release build). Each value is the median of 100 `cargo bench` samples. ### Prompt Timeout Prompt timeout is disabled by default. If you enable it, modules that do not finish before the timeout show `...` instead of blocking the prompt. This is a latency tradeoff for slow filesystems like network drives, WSL2 `/mnt/c/`, or NFS mounts. Benchmark mode ignores this setting so `--bench` measures the actual module work instead of the timeout fallback. **Why is it fast?** - Zero-copy parsing with SIMD optimizations - Efficient memory allocation strategies - Context-aware detection (only checks what's needed) - No async operations or network calls - Written in Rust for maximum performance ## Command-Line Options ## Building from Source ## License License [The MIT License](./LICENSE) Copyright (c) 2025 Ivan Zakharchanka