How to change the bash terminal prompt color?

Operating System: Fedora Linux 38
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.10
Kernel Version: 6.4.9-200.fc38.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i5-7200U CPU @ 2.50GHz
Memory: 23.1 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 620
Manufacturer: Dell Inc.
Product Name: Inspiron 15-3567

This is my current terminal prompt:
Screenshot_20230812_112534

And this is how it looks like above and below an output in the terminal:
Screenshot_20230812_112448

As you can see, the prompt is small and hard to see among long text outputs. So i want a way to colorize the prompt so it stands out and becomes clearly visible among too much output text. It would be nice to colorize the prompt to green and draw a line after each output.

I checked this change but it didn’t help me.

Also i tried doing this

export PS1="\e[0;32m[\u@\h \W]\$ \e[0m"

in .bashrc but it didn’t work well at first and and the output was sometimes malformed.

Any ideas ?

1 Like

Use \[ before and \] after non-printing escape codes. Also close and reopen your terminal after changing your .bashrc file.

export PS1="\[\e[0;32m\][\u@\h \W]\$ \[\e[0m\]"
2 Likes

I tried this

export PS1='\[\e[1;31m\]\u\[\e[1;32m\]@\h\[\e[1;36m\]:\w\[\e[0m\]-$ '

and it seems to be working fine
Screenshot_20230812_115515

2 Likes