PS1 generator inputs
Prompt elements:
Use Add token, then open rows to edit token values, colors, and attributes.
Use separators such as @, :, spaces, brackets, or short labels.
Use variable names like PATH, HOME, PWD, or USER.
Use strftime patterns such as %F, %a %H:%M, or %Y-%m-%d.
Choose a high-contrast #RRGGBB color for the token text.
{{ element.colorBG ? 'Current background ' + element.colorBG + '.' : 'Leave off for transparent prompt text.' }}
{{ element.colorBG ? 'On' : 'Off' }}
Toggle bold, dim, underline, reverse, hidden, or blink per token.
{{ attribute.label }}
Examples: \n for a new line, [, or leave blank.
Examples: \$ for root-aware prompt char, >, trailing space, or blank.
Use a space, -, :, or blank.
Paste one PS1, for example \u@\h:\w\$ .
Prompt parser
Use #000000 for a dark terminal sample or choose your terminal theme color.
Sample terminal preview

            
PS1 value

            
Element PS1 snippet Copy
{{ row.label }} {{ row.snippet }}
No elements.
Item Value Copy
{{ row.label }} {{ row.value }}
Customize
Advanced
:

A shell prompt is the last thing you see before a command runs, so small prompt choices can prevent expensive mistakes. A remote production shell, a local development tree, a container session, and a temporary root shell may all accept the same commands while meaning very different things. A useful prompt gives just enough context to slow down the wrong command and speed up the routine one.

PS1 is the Bash variable that defines the primary interactive prompt. Its value can combine literal text, Bash prompt escapes, shell variables, command substitutions, date and time formats, line breaks, and terminal styling sequences. Bash expands those pieces each time it draws the prompt, which lets one saved string show the current user, host, directory, time, exit code, job count, or branch as the session changes.

Anatomy of a Bash PS1 prompt A terminal prompt labelled with user, host, path, exit status, and prompt character sections. alice @ zeus : ~/src/app 0 $ user host path status prompt A PS1 prompt can join Bash escapes, literal text, shell expansions, and non-printing ANSI style markers.
Identity
User and host clues separate local, remote, container, and administrator shells before the next command is typed.
Location
Directory and branch clues reduce wrong-tree edits, especially when several terminals are open.
State
Exit status, job count, date, time, and shell version can reveal context that may have scrolled away.
Shape
Color, punctuation, and line breaks improve scanning only when the prompt still leaves enough room for commands.

Prompt design is a balance between signal and space. A compact SSH prompt may only need user, host, directory basename, and a root-aware prompt character. A development prompt may justify a previous exit status, a branch hint, or a line break before the command area. Loading every available signal into PS1 usually makes the prompt harder to read and easier to ignore.

A prompt is still a reminder, not a safety system. A branch name does not prove the working tree is clean, a host label does not make a destructive command safe, and a green exit code only describes the previous command. Use the prompt as a fast orientation aid, then verify the command, path, host, and privileges before high-risk work.

How to Use This Tool:

Start with the few facts you need before each command, then build the prompt from ordered pieces. Keep the first draft simple enough to test in a temporary shell.

  1. Choose Add token under Prompt elements for built-in pieces such as Username, Hostname (short), Working Dir, Exit Status, Git Branch, New Line, or Prompt Char.
  2. Add Text tokens for separators such as @, :, brackets, labels, or spaces. Reorder rows until the sample prompt reads in the same order you expect at the command line.
  3. Open a token row to set foreground color, optional background color, and attributes such as bold, dim, italic, underline, blink, or reverse.
    Fix any warning about an invalid #RRGGBB value before copying the generated prompt.
  4. Use Advanced when you need a prefix, suffix, delimiter, existing prompt import, or preview background. A delimiter inserts the same text between neighboring tokens, while separate Text tokens give more exact control over punctuation.
  5. Paste an existing value into Import existing PS1 when you want a starting point.
    The importer recognizes common Bash prompt escapes, variables, dates, newlines, prompt characters, and command substitutions. Unusual quoting or custom shell logic still needs manual review.
  6. Read Generated PS1, Element Breakdown, Setup Notes, and JSON. Copy or download the artifact that matches your next task.
  7. Test the copied value in a temporary Bash session before adding it to a startup file such as ~/.bashrc.
    Try a long path, a failed command, a Git repository when branch output is used, and a root shell if the prompt character matters.

Interpreting Results:

The sample preview helps with spacing, color, and rough readability, but it is not a transcript from your shell. Bash resolves the final values from the live session whenever it displays the prompt.

How to interpret PS1 generator result sections
Result section What it tells you What to verify yourself
Generated PS1 The prompt value to copy into Bash. Whether your startup file, Bash settings, terminal, and command substitutions support the pieces you chose.
Sample terminal preview How the prompt may look with sample user, host, path, branch, time, and status values. Real runtime values, prompt wrapping in your terminal, and font or color differences.
Element Breakdown Each ordered token and the PS1 snippet it contributes. Whether the order still makes sense after imports, duplicates, delimiter changes, or line breaks.
Setup Notes A Bash assignment form, non-printing marker reminder, and any extra setup needed for branch output. Which startup file your environment actually reads and whether sourced functions are available in new shells.
JSON A saved record of inputs, generated prompt, table rows, and warnings. Runtime shell output. The JSON is a configuration record, not proof that Bash accepted the prompt.

If the installed prompt looks wrong, remove styling first, then command substitutions, then custom date formats. Cursor wrapping problems often point to unmarked non-printing bytes, while missing branch text usually points to a missing shell function.

Technical Details:

Bash prompt expansion has two important phases. Backslash escapes such as \u, \h, and \w are decoded into prompt text. When prompt variable expansion is enabled, Bash can then perform shell expansion on the decoded result, so $?, $HOME, and $(id -u) can change each time the prompt is drawn.

ANSI styling requires special handling because color and attribute bytes do not occupy visible terminal columns. Bash uses \[ and \] around non-printing sequences so command-line editing, backspacing, and wrapping stay aligned. Without those markers, a prompt may appear correct until a long command reaches the edge of the terminal.

Generation Path:

  1. Join the prefix, ordered prompt elements, delimiter text, and suffix into one prompt value.
  2. Convert token choices into Bash prompt escapes, shell variables, literal text, or command substitutions.
  3. Add ANSI color and attribute sequences around styled tokens, with Bash non-printing markers around those bytes.
  4. Reset styling after each styled token so color or text attributes do not leak into later prompt text.
Representative Bash PS1 tokens and runtime meanings
Prompt choice PS1 snippet Runtime meaning
Username \u Current user name.
User ID $(id -u) Numeric user ID from a command substitution.
Hostname (short) / Hostname (full) \h / \H Host name before the first dot, or the full host name.
Working Dir / Dir (basename) \w / \W Current directory path, or only the final path segment.
Bash Version / Shell Release / Shell \v / \V / \s Bash version, Bash release, or shell basename.
Date and time \d, \D{format}, \t, \A, \T, \@ Built-in date and time forms, including custom strftime patterns.
History # / Command # / Jobs \! / \# / \j History number, current command number, or active job count.
Exit Status $? Exit code from the previous command after shell expansion.
Env Variable $NAME Value of a valid shell variable name when the prompt is displayed.
Git Branch $(parse_git_branch) Branch text from a shell function that must exist in the Bash session.
Prompt Char / New Line / Text \$, \n, literal text Root-aware prompt character, line break, or escaped literal characters.

Custom date prompts use the same formatting vocabulary as strftime. Patterns such as %F, %H:%M, %a, and %B are useful for compact dates, 24-hour time, weekday names, and month names. Locale and time zone settings can change the rendered text, so the preview is a guide to common patterns rather than a guarantee for every shell environment.

Validation checks used by the PS1 generator
Area Accepted form Why it matters
Foreground and background colors #RRGGBB hex color values. Invalid colors cannot be converted into the ANSI true-color sequences used for styled prompt tokens.
Variable names Start with a letter or underscore, followed by letters, numbers, or underscores. Names such as 9PATH are not valid shell variable names.
Custom dates A non-empty format string inside the custom date escape. An empty date format leaves Bash with no useful pattern to expand.
Imported prompts Common Bash prompt escapes, variables, prompt character, newlines, dates, and command substitutions. An importer can split recognizable pieces, but it cannot fully understand every hand-written shell expression.

Two counters are easy to confuse. \! uses the shell history number, while \# uses the command number in the current shell session. They can differ because history may include commands loaded from earlier sessions.

Limitations and Privacy Notes:

The generated value is a prompt draft for Bash, not a complete shell configuration audit. It can make valid prompt syntax easier to assemble, but the real behavior still depends on your Bash version, startup files, terminal emulator, fonts, colors, shell options, and any functions or commands referenced by the prompt.

  • Prompt building, previewing, warnings, copying, and exports run in the browser after the page loads.
  • Do not paste secrets into literal text, variables, or command substitutions. A prompt is visible in the terminal and may end up in screenshots, recordings, or shared configuration files.
  • Test risky additions in a temporary shell before saving them permanently. Command substitutions can slow the prompt or behave differently across hosts.

Worked Examples:

Compact SSH prompt

For a remote shell in a narrow terminal, combine Username, a Text token set to @, Hostname (short), a Text token set to :, Dir (basename), and Prompt Char. Leave the delimiter blank so punctuation tokens control the spacing. The generated value should include \u, \h, \W, and \$.

Development prompt with previous status

A repository prompt can show failure state before the next command. Use Exit Status, Working Dir, Git Branch, New Line, and Prompt Char. Check Setup Notes before installing it because branch output depends on a shell function being available in new Bash sessions.

Imported prompt with a custom date

A prompt such as \u@\h:\w \D{%F} \$ should import as user, host, path, date, and prompt-character tokens. If you then add an environment variable named 9PATH, the warning list should flag it because Bash variable names cannot begin with a digit. Rename it to PATH or another valid name before copying.

FAQ:

Does this generate prompts for zsh or PowerShell?

No. The generated value uses Bash prompt escapes and Bash shell expansion syntax. Other shells have different prompt variables, escape rules, and startup files.

Why do styled prompts need special non-printing markers?

ANSI color and attribute bytes change terminal display but do not add visible columns. The markers \[ and \] tell Bash not to count those bytes when editing and wrapping the command line.

Why does the preview differ from my real terminal?

The preview uses sample values and a limited date formatter. Your real shell supplies the actual user, host, path, date, exit status, variables, command substitutions, terminal font, and color rendering.

What happens if I use Git Branch without the setup note?

The generated prompt expects a branch function to exist in the Bash session. If the function is missing, the branch part will not behave like the preview.

Can the importer rebuild every existing PS1 exactly?

No. It recognizes common prompt escapes, variables, dates, newlines, prompt characters, and command substitutions. Prompts with unusual quoting, embedded shell logic, or terminal control tricks still need manual review.

Does my prompt text leave the page for processing?

Prompt building, previewing, warning checks, copying, and exports run in the browser after the page loads.

Glossary:

PS1
The Bash variable expanded before the primary interactive prompt is displayed.
Prompt escape
A backslash sequence such as \u or \w that Bash replaces with shell state.
Shell expansion
The Bash step that can resolve variables, command substitutions, arithmetic expansion, and quotes after prompt escapes are decoded.
Command substitution
A shell expression such as $(id -u) that runs a command and inserts its output.
Non-printing sequence
Terminal control bytes that change display without occupying visible prompt columns.
Delimiter
Text inserted between neighboring prompt elements.
strftime
The date-format vocabulary used by Bash custom date prompt escapes.