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
Posts: 4294
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.
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),Aeromodelling,1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

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.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Return to “Beginners”