MAKE UR OWN PROMPT

Custom Bash Prompt

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.

My prompt style:

(disu1950𝕏localhost)-[~]

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.

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

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.

Bash $PS1 Generator2.0

https://www.kirsle.net/wizards/ps1.html

Color Codes (ANSI Escape Sequences)

Foreground colors, Normal (non-bold) is the default, so the 0; prefix is optional.

\e[0;30m = Dark Gray
\e[1;30m = Bold Dark Gray
\e[0;31m = Red
\e[1;31m = Bold Red
\e[0;32m = Green
\e[1;32m = Bold Green
\e[0;33m = Yellow
\e[1;33m = Bold Yellow
\e[0;34m = Blue
\e[1;34m = Bold Blue
\e[0;35m = Purple
\e[1;35m = Bold Purple
\e[0;36m = Turquoise
\e[1;36m = Bold Turquoise
\e[0;37m = Light Gray
\e[1;37m = Bold Light Gray

Background colors:

\e[40m = Dark Gray
\e[41m = Red
\e[42m = Green
\e[43m = Yellow
\e[44m = Blue
\e[45m = Purple
\e[46m = Turquoise
\e[47m = Light Gray

Reset to default:
\e0m

Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.