In Unix-like shells, the primary prompt string, known as PS1, precedes every command you enter. It blends plain characters with escape sequences such as \u
for username or \w
for the working directory, which the shell evaluates on each render. A thoughtfully designed prompt improves situational awareness, quickens navigation, and reduces costly directory or host mistakes.
The in-browser generator arranges colour swatches, formatting toggles, and predefined tokens into a list that the reactive engine converts into a valid Bash escape-based PS1 string. Each element can carry foreground, background, and text attributes; optional prefix, suffix, and delimiter settings wrap and join the sequence, while a live preview instantly reflects your selections against any background.
Use it before provisioning new cloud instances to embed host-colour cues, or when sharing tutorials so readers copy an unmistakable prompt without hand-editing escape codes. Exercise caution when pasting lengthy PS1 strings into production scripts because unintended control characters can affect logging, SSH banners, or non-interactive build pipelines and automated testing environments.
Bash interprets PS1 each time it draws the prompt. The string may include backslash-escaped tokens, ANSI colour codes, command substitutions, or user-defined variables. When rendering, the shell replaces each token with real-time context, wraps it in non-printing escape sequences accepted by terminal emulators, then resets attributes to avoid colour bleed. Properly balanced control characters keep cursor positioning accurate during line editing.
prefix
, delimiter
, and suffix
global options.[
, ]
, and backslashes so Bash treats them as printable.Token | Expansion |
---|---|
\u | Current user name |
\h | Hostname (short) |
\w | Current working directory |
\D{<fmt>} | Formatted date string |
\$ | Prompt character (# for root, $ otherwise) |
The shell prints tokens sequentially. Colour and attribute sequences wrap only the characters they precede; therefore, missing reset codes may shift the prompt or subsequent command output.
Example inputs
$ prefix="" | elements=[\u (green bold), '@' (white), \h (green), ':' (white), \w (blue)] | suffix="$"
Shell renders
$begin:math:display$\\e[1;38;2;0;255;0m$end:math:display$\u$begin:math:display$\\e[0m$end:math:display$@$begin:math:display$\\e[38;2;255;255;255m$end:math:display$\h$begin:math:display$\\e[0m$end:math:display$:$begin:math:display$\\e[38;2;0;128;255m$end:math:display$\w$begin:math:display$\\e[0m$end:math:display$$
\D{}
custom date token.$begin:math:display$
and end with $end:math:display$
to preserve cursor math.Reference: GNU Bash Manual §6.9 “Prompting”; XTerm Control Sequences (with 24-bit colour additions).
No personal data leaves your browser; generation is executed entirely client-side and falls outside GDPR scope.
Follow this sequence to craft and install a prompt that matches your workflow.
~/.bashrc
; reload with source ~/.bashrc
. Take care on production serversPS1 is Bash’s “primary prompt string”, the text displayed each time the shell expects a new command.
No. All generation happens locally; nothing is transmitted or written beyond your own clipboard.
Remove or comment the PS1 line in your shell startup files and restart the terminal; Bash then falls back to its default prompt.
Colour vibrancy depends on your terminal’s 24-bit colour support and theme; switch to a true-colour emulator for full fidelity.
Yes. Paste your current string into the import field; the tool parses known tokens and lets you edit them graphically.