Bash $PS1 Generator2.0

This tool will help you generate a custom colorful bash prompt for Unix-like operating systems, including Linux and Mac OS X. [Help]

Preview This is a "live" preview of how your custom bash prompt will look in a terminal:

_

Set preview background color: [Dark | Light]

Components You will construct your custom bash prompt by defining it one component at a time. The components are processed in order, so for example if one component sets the color to "red", text in the following component will have red text.

You can use the following bash keywords in any "Text" component. See `man bash` for a more complete list:

	\u  The name of the logged-in user
	\h  The hostname up to the first '.'
	\H  The full hostname
	\n  Newline
	\$  Shows a $ for a regular user or # for root user
	\\  A literal backslash "\" character

Preset themes:

Delete Type Data Move
delete delete   Up Up / Down Down

Result Paste the following output into your ~/.bashrc or equivalent file:

Help This is an interactive tool to aid in setting a custom (and colorful) bash command prompt.

Unlike other prompt generating tools that insert ANSI escape sequences to set colors for your prompt, this one uses the bash \[$(...)\] sequence to use the tput command to set the colors. This means that bash has a more accurate internal idea of how long your prompt is, so that word wrapping for example behaves correctly as you enter a long command.

How to Use

You'll construct a custom bash prompt by using the Components builder above. The components are processed in order, so for example if you have a "Set color -> red" followed by text, that text will be displayed in red in your bash prompt.

A live preview (generated via JavaScript) will give you a rough idea how your prompt is going to look so far. It has built-in support for handling common bash keywords such as \u and \h, but it won't process more complicated ones. The final output for your .bashrc file will be shown in the "Result" box that you can paste into your .bashrc. Starting a new bash shell after saving the changes should show your new bash prompt.

Examples

Select a theme preset from the dropdown above the component builder to select an example theme, and study how it was pieced together.

Author

Noah Petherbridge, www.kirsle.net.

This is "Version 2.0" of my $PS1 generator, updated to use Knockout.js and have more features. My older version that doesn't rely on any external JS libraries is still available here: ps1-10.html.

Code last updated on April 25, 2014.