Zbot473
Posts: 7
Joined: Fri Aug 07, 2015 8:26 pm

Change username color in shell

Thu Mar 22, 2018 10:40 pm

Is there a way to change the name of the username in the .bashrc file?
I am using the same .bashrc file for the root user, and I just want the color of the username to be red, so I don't break the pi accidentally.

User avatar
PeterO
Posts: 4420
Joined: Sun Jul 22, 2012 4:14 pm

Re: Change username color in shell

Thu Mar 22, 2018 11:09 pm

Look for the setting of PS1 in .bashrc
There are some escape sequences in it that set the colours.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
DougieLawson
Posts: 34775
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Change username color in shell

Fri Mar 23, 2018 1:03 am

Code: Select all

    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
Gives you a red prompt.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

Return to “Beginners”