Bash PS1 Generator
Compose PS1 with ANSI colors, user, host, pwd, git branch and last exit code. Live prompt preview.
PS1:
—
Preview aproximado:
—
Building a bash prompt without memorising the codes
The variable defining the bash prompt takes a collection of backslash escapes: user, host, directory, time, the symbol that changes depending on whether you are root. Memorising that does not pay off — there are more than twenty codes and nobody touches their prompt often enough to retain them.
Pick the elements and the colours and the page assembles the variable. The technical detail causing the most trouble shows up right there: colour sequences must sit between the non-printing start and end markers. Without them, bash counts the invisible colour characters in the prompt length, and the result is the command line overwriting itself when you scroll history or edit a long command.
To apply permanently, the definition goes in the file read by interactive shells, typically ~/.bashrc. Worth remembering that there is also the continuation prompt variable, the one appearing when a command is incomplete, and the trace one used when script debugging is enabled — if you have ever got lost in a script with many repeated lines, configuring that last one with the line number helps a great deal.
Frequently asked questions
Why does my prompt scramble when I scroll history?
How do I show the Git branch in the prompt?
Can I show the previous command's exit code?
Related Tools
Shell Argument Escaper
Quote a string safely for bash/sh, wrapping in single quotes and handling embedded quotes.
Bash/Zsh Aliases Generator
Predefined list of useful aliases (ll, la, gs, gd, gco, mkcd, ip) ready to paste into .bashrc or .zshrc.
Cron Expression Editor
Parse and build cron expressions with human-readable descriptions, next execution times and shortcuts for common schedules.
URL Analyzer
Decompose any URL into its components: protocol, host, pathname, query parameters and hash. Inspect query strings individually.
NGINX Rate Limit Generator
Configure limit_req_zone and limit_req in NGINX to rate limit per IP. Includes configurable burst and nodelay.
Tailwind Config CLI Generator
Generate a ready-to-use tailwind.config.js for the Tailwind CLI, with content paths and theme set up. Copy it and start styling in seconds.