If you selected Git Branch, add this helper to your shell rc before setting PS1:
parse_git_branch() { git branch --show-current 2>/dev/null | awk 'NF{print " (" $0 ")"}'; }
| Element | PS1 Snippet | Copy |
|---|---|---|
| {{ r.label }} | {{ r.snippet }} | |
| No elements. | ||
A shell prompt is the text you see before each command, and small mistakes in that line can have outsized consequences. The wrong host, the wrong directory, or an invisible non-zero exit status is often how a routine terminal session turns into cleanup work. This generator assembles a Bash-style PS1 string so that the prompt can carry that context in a form you can read quickly.
The tool lets you build the prompt from ordered elements such as user, host, working directory, time, shell details, exit status, history number, jobs, environment variables, plain text, and an optional Git branch helper. It then shows a styled sample preview and the literal string you would place in a shell startup file. That is much easier than shaping a prompt by hand out of escapes, color codes, and repeated trial-and-error edits.
That matters in ordinary work, not only in elaborate terminal themes. A short prompt can keep SSH sessions readable, a development prompt can keep branch and path visible, and a two-line prompt can separate status information from the next command line so errors stop blending into everything else.
The package also has clear boundaries. The preview uses sample values rather than your live shell state, the output is written for Bash-style PS1 syntax, and the import field is a convenience parser rather than a complete shell prompt decompiler. Those limits are useful to know before you trust the copied string.
The cleanest prompts usually start small. A baseline of user, host, directory, and prompt character is enough for many shells, and it keeps the first version readable while you decide which extra signals are actually worth the space.
Once that core works, add context only when you expect it to change what you do next. Exit status matters when you debug or automate. A branch marker matters when you spend most of your time inside repositories. Time markers matter when session timing or command history discipline actually affects the work.
@, :, brackets, or separators instead of baking those characters into one large literal block.user@host:path layout. Use a visible delimiter only when you want extra spacing between semantic units.$(...) logic still needs manual review.The page works best when you use it to shape the structure, then test that structure in a fresh Bash session where directory changes, branch changes, root prompts, and failing commands can all reveal whether the prompt is doing the job you intended.
PS1 is the Bash variable expanded before the shell reads the next command. This generator builds that string from prompt escapes, shell expansions, and literal text. Some elements map to native Bash prompt escapes, while others emit ordinary shell syntax that Bash resolves later when the prompt is drawn.
| Element | Emitted snippet | Practical meaning |
|---|---|---|
| Username | \u |
Shows the current user name |
| Hostname (short) | \h |
Shows the host name up to the first dot |
| Working Dir | \w |
Shows the current directory with home abbreviated |
| Dir (basename) | \W |
Shows only the last path segment |
| Date (custom) | \D{format} |
Uses a strftime-style format string at prompt time |
| History # | \! |
Shows the history list entry number |
| Command # | \# |
Shows the current-session command count |
| Prompt Char | \$ |
Shows # for effective user ID 0 and $ otherwise |
| User ID | $(id -u) |
Runs a command substitution that resolves to the numeric user ID |
| Git Branch | $(parse_git_branch) |
Calls the helper function shown in the page so the current branch can appear when present |
Two details from Bash matter more than they first appear. History # and Command # are not interchangeable, because Bash distinguishes the position of a command in the saved history list from the sequence number of commands executed in the current shell session. Likewise, custom dates in \D{...} are expanded by Bash itself using strftime-style formatting rules.
Element styling is applied one token at a time. When you choose a foreground color, background color, or text attribute, the tool emits ANSI styling around that token and then resets the style afterward. Those non-printing bytes are wrapped inside Bash prompt delimiters so cursor movement and line editing do not miscount invisible characters as visible width.
The preview and the copied string have different jobs. Live Preview substitutes sample values such as alice, zeus, main, and representative environment values so spacing and visual emphasis are easy to judge. Generated PS1 preserves the prompt escapes and shell expansions that Bash must interpret later, which is why the preview can look resolved while the copied string still contains prompt syntax.
The importer is intentionally partial. It recognizes common prompt escapes, environment variables, custom date blocks, newline markers, $(id -u), and generic command substitution shapes. Any generic $(...) block is rebuilt as the tool's Git-branch element, which makes import useful for rough reconstruction but unsuitable as proof that the original prompt has been recreated exactly.
The page also has a narrower date preview than Bash itself. The sample renderer covers common year, month, day, hour, minute, second, weekday, and month-name tokens, which is enough for most prompt mockups, but Bash can interpret a broader \D{format} pattern at runtime than the preview can fully demonstrate. This tool remains browser-only throughout, so prompt generation, validation, and export preparation all happen on the page.
Build the structure first, then test the literal output in a real shell.
$(...) segments that were approximated as branch output.A finished prompt should remain readable, keep cursor alignment intact while you edit commands, and still make sense when host, directory, branch, or exit status changes.
The page gives you three views of the same configuration. The preview is for layout, the table is for inspecting each emitted snippet, and the copied PS1 string is the actual shell artifact. If those three disagree in your head, trust the string that Bash will read rather than the mock preview.
A prompt is successful when it stays readable in the terminal you actually use and exposes the context you rely on before you type the next command. That judgment belongs to the real shell, not just the preview box.
A remote prompt often benefits from restraint. Use Username, a Text element containing @, Hostname (short), another punctuation element, Dir (basename), and Prompt Char, then leave the delimiter empty. The result keeps identity and location visible without wasting columns on a narrow terminal.
Suppose you want path and branch on one line and the next prompt on another. Add Exit Status, Working Dir, Git Branch, and New Line, then finish with Prompt Char. That layout separates the status signal from the command entry point so a failing command is harder to miss. It also makes the Git helper requirement obvious, because branch output only appears once the helper function is present in the shell startup file.
Paste a prompt that contains a generic command substitution such as $(date) and the importer can recognize the shape of the expression, but it does not rebuild a general command element. Instead, the package routes the segment into its branch-style placeholder, which is your cue to replace it manually with a built-in date element, a text block, or a different structure before you trust the output.
No. The preview, warning checks, table export data, JSON payload, and generated PS1 string are all assembled in the browser, and this slug does not ship a backend helper.
The output is a Bash-style PS1 string. It uses Bash prompt escapes and Bash-style shell syntax, so it is not a PowerShell prompt function and it does not generate zsh theme syntax.
The preview uses sample values and a limited date formatter so you can judge layout quickly. The shell still resolves variables, dates, command substitutions, root-versus-user prompt characters, and branch output at prompt time.
Bash treats them as different counters. One refers to the history list entry, while the other refers to the command sequence number within the current shell session.
It defines the parse_git_branch function that the generated branch snippet calls. Without that helper in your shell startup file, the copied prompt string cannot show branch names the way the preview implies.
\u or \w that expands into prompt content.$(id -u) that runs a command and inserts its output.