Free tools Windows power users keep installed
One-click scans. No signup required.
To change an interactive Bash prompt’s color, assign PS1 a terminal color sequence and put Bash’s [ and ] markers around the non-printing sequence:
PS1='[e[31m]u@h:w$ [e[0m]'
This example requests a red prompt, then resets the color before you type a command. It displays the username, short hostname, working directory, and a prompt character that changes for the effective user. The terminal must interpret the color sequence for the color to appear.
What the Bash prompt assignment does
Bash uses PS1 as its primary prompt in interactive use. When it displays the prompt, Bash expands recognized escapes and sends the resulting output to the terminal. The terminal, not Bash, interprets the color-control sequence. For the prompt escapes and control-sequence markers, see the GNU Bash Reference Manual’s “Controlling the Prompt” page.
[and]mark a non-printing portion of the prompt. Use them around terminal control sequences so Bash can account for the visible prompt correctly during command-line editing.erepresents the escape character that begins the terminal control sequence.[31mrequests red text in the example;[0mresets the terminal’s text formatting.u,h, andwexpand to the username, short hostname, and current working directory.$displays a prompt character that reflects whether the effective user is the superuser.
Test the color in the current Bash session
-
Confirm that the interactive shell is Bash. This prompt syntax relies on Bash’s prompt expansion and does not apply unchanged to zsh, fish, or a POSIX
shimplementation.The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
At the Bash prompt, enter:
PS1='[e[31m]u@h:w$ [e[0m]'The prompt should change immediately. This assignment applies to the current shell session only.
-
Check that the prompt is readable and that the cursor behaves correctly when editing a long command. If it does not, confirm that each non-printing control sequence is enclosed by
[and].Rank #2
Make the change persist
After confirming the assignment works, add it to the Bash interactive startup configuration used on your system. Which startup file Bash reads can depend on how the shell is started and the system’s configuration, so use the file appropriate to your setup. Put the assignment there, then open a new interactive Bash session to check it.
Adjust the prompt color
Change the color number in the opening control sequence to request a different terminal color. For example, replace 31 in e[31m with the color code you want to try. The exact appearance depends on the terminal and its palette; Bash provides the prompt-string mechanism but does not guarantee identical rendering in every terminal.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesRank #3
Troubleshoot common problems
- The codes appear as text or no color appears: Check that you are in Bash, that the assignment uses the shown quoting, and that the terminal interprets the selected control sequence.
- The cursor or long-line editing is misaligned: Make sure every non-printing control sequence is between
[and]. Bash’s prompt documentation defines these markers for non-printing prompt material. - Typed commands inherit the prompt color: Keep a reset sequence such as
[e[0m]before the input position. The example places it after the prompt text and before the space where you type. - The setting has no effect in another shell: Verify that the running interactive shell is Bash; other shells may use different prompt syntax.
Why this applies to interactive Bash
Bash uses Readline to read commands in interactive shells, and displays PS1 as the primary prompt. This distinction matters: Bash expands the prompt string, while the terminal-compatible environment interprets its control bytes. The GNU Bash Reference Manual’s “Interactive Shell Behavior” page describes prompt display and Readline use.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

