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: 4032
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),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
DougieLawson
Posts: 32058
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\]\u@\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, 3B*3, 3B+

Please post ALL technical questions on the forum. Do not send private messages.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 27 guests