Chris Collins

Tools · systems

Shell prompt builder

Build a zsh PROMPT/RPROMPT and a bash PS1 from blocks — user, host, directory, git branch and state, exit status, time, venv — with a live preview in several terminal colour schemes; paste any prompt to see it expanded and explained escape by escape; and paste zprof or a timed xtrace log to find what makes zsh slow to start.

Added

How to use it

A prompt is a small program written in two different escape languages — zsh’s %n %~ %F{…} %(?.…) and bash’s \u \w \[\e[32m\] — and a mistake shows up as a wrong colour, a cursor in the wrong place, or a shell that takes a second to open. This page builds prompts, reads them back to you, and reads zsh’s start-up profiles.

How to use it

The bar at the top describes a sample machine for every preview: the terminal colour scheme, the last command’s exit status, whether you’re in a git repository (clean, changed, staged, rebasing), the directory, a Python virtualenv, background jobs, and root.

  1. Build: start from a preset or add blocks — user, host, directory (full or just its name), git branch, exit status if it failed, time, jobs, virtualenv, a ❯ that turns red after a failure, text, new lines — and give each a colour (the 16 named ones, any of 256, or #rrggbb), bold, and for zsh the right-hand side. The preview shows zsh and bash side by side. Below are the lines for ~/.zshrc (with vcs_info set up) and ~/.bashrc (with git-prompt.sh’s `__git_ps1, every escape wrapped in \[ \], and the exit status saved by PROMPT_COMMAND).

  2. Explain a prompt: paste a PROMPT=… or PS1=… line from your dotfiles (quotes and all). Each escape gets a line saying what it does — conditionals, truncation, strftime formats, colours, command substitutions — and the expanded prompt is drawn underneath. It warns about colour codes outside %{ %} or \[ \], which make long command lines wrap over themselves.

  3. Start-up profiler: paste the table zprof prints, or a trace log with timestamps (How to capture has the lines to put in ~/.zshrc). You get the slowest functions, or the slowest lines including everything they source or call, time per file, and the usual culprits with what to do about them: nvm, compinit run twice or without its cache, Oh My Zsh plugins, eval "$(brew shellenv)", pyenv/rbenv/conda init, generated completions such as kubectl completion zsh.

Commands inside the prompt ($(…)) can’t run here: __git_ps1, git branch, tput, date, whoami and hostname are simulated from the sample machine, and anything else is shown as a placeholder.

Checked against

The expansion engine was compared with real zsh 5.9 (print -P, including %(…) conditionals, %N<…< truncation and colours) and bash 5.3 (${PS1@P}) on macOS 27, escape sequences included; those cases are in the tests. Built prompts were run in both shells in a scratch git repository with the real vcs_info and git-prompt.sh. The profiler’s parsers were tested on output from real zprof and xtrace runs.

For explaining whole commands, see the shell command explainer; to try things in a real shell, the Linux shell.

Browser support

Any current browser.

Privacy

Everything happens in your browser. What you paste is not uploaded, and the page loads no outside scripts. A share link carries only the blocks you built.

Runs entirely in your browser; nothing you type leaves this page.