Bash/shell prompt in different colors for root and users

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

Bash/shell prompt in different colors for root and users

Postby ca-on-adam » Dec 18th, '13, 10:25

Hi,

I liked the green prompt on Linux Mint, and upon seeing it reproduced in the Debian release for Raspberry Pi, I thought "Hey, why don't I figure out how to do that!"

Don't ask me why I thought of purple. Everywhere on the site, Mageia's theme is blue, but I still associate purple with Mageia. But blue is used for the working directory in Linux Mint, so it would have been boring for the prompt and pwd to be the same colour.

Into my home .bashrc file, I added:
Code: Select all
# Purple, bold='\033[1;35m'
PS1='\[\033[1;35m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '


Enjoy!

Newbie's note: Don't confuse the square brackets in mageia's default prompt for special characters, they are not! The default prompt includes square bracket's for style only:
Code: Select all
$ echo $PS1
[\u@\h \W]\$

None of the brackets in the special colour codes should be showing up at your actual prompt.

ref: Linux Mint 13 .bashrc file
ref:https://wiki.archlinux.org/index.php/Color_Bash_Prompt#Step_by_step
Last edited by doktor5000 on Dec 23rd, '13, 23:41, edited 1 time in total.
Reason: adjusted thread title
ca-on-adam
 
Posts: 57
Joined: Aug 31st, '11, 13:33

Re: Purple bash prompt for Mageia

Postby doktor5000 » Dec 18th, '13, 14:34

Moved to Tips&Tricks subforum.

On a related note, easiest thing for a default installation is to install colorprompt, adds a green prompt for users and red one for root, systemwide.
Can also be easily adapted.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Purple bash prompt for Mageia

Postby isadora » Dec 18th, '13, 14:58

Thanks doktor5000, works like a charm, out-of-the-box. :)
..........bird from paradise..........

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
—Antoine de Saint-Exupéry
User avatar
isadora
 
Posts: 2742
Joined: Mar 25th, '11, 16:03
Location: Netherlands

A simple, informative change...

Postby zxr250cc » Mar 5th, '14, 19:37

With regard to shell usage as root, it would be nice if the root user name and the computer name changed from the default system color to red colored letters to indicate a root shell. I won't mention other distro names but there are others who do this and it is visually very easy to remember you are in a root shell that way.

When using root as a log in I set the cursor to red as a reminder and think that the red colored letters for the shell usage would serve the same visual function.

Cheers all

zxr250cc
'We live in the best of all possible worlds!'
Candide (Voltaire)
User avatar
zxr250cc
 
Posts: 200
Joined: Mar 25th, '12, 23:20
Location: USA, Central time zone

Re: A simple, informative change...

Postby jkerr82508 » Mar 5th, '14, 20:01

Install the package colorprompt
"A little bash profile extension to color your user prompt appropriately.
It will make regular logins green and root logins red."

Jim
jkerr82508
 
Posts: 946
Joined: Mar 26th, '11, 01:34
Location: Fife, Scotland

Re: A simple, informative change...

Postby isadora » Mar 5th, '14, 20:02

Try installing colorprompt from repositories.

edit: you were to fast for me jim ;)
..........bird from paradise..........

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
—Antoine de Saint-Exupéry
User avatar
isadora
 
Posts: 2742
Joined: Mar 25th, '11, 16:03
Location: Netherlands

Re: A simple, informative change...

Postby doktor5000 » Mar 6th, '14, 02:22

Next time please use the search function. Existing thread in our tips&tricks subforum:
Bash/shell prompt in different colors for root and users
-> first result in forum search when looking for "shell prompt color"

:|

edit doktor5000: merged with existing thread
Please next time use a more meaningful title too, does never hurt for others who do use search function.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Bash/shell prompt in different colors for root and users

Postby jiml8 » Mar 8th, '14, 05:08

*I* dare to be different! I use a yellow prompt for root, not red. Though most of my Linux VMs use red, by default...
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: Bash/shell prompt in different colors for root and users

Postby zxr250cc » Mar 9th, '14, 15:57

My idea in posting was not that I could add the function with a download but that it would be there by DEFAULT like several other distributions so it is more informative. I did a search for colored root fonts and came up with zip so I posted with my heading. Thanks for the reply about the needed download. It worked fine.

cheers all
'We live in the best of all possible worlds!'
Candide (Voltaire)
User avatar
zxr250cc
 
Posts: 200
Joined: Mar 25th, '12, 23:20
Location: USA, Central time zone

Re: Bash/shell prompt in different colors for root and users

Postby doktor5000 » Mar 9th, '14, 21:30

zxr250cc wrote:My idea in posting was not that I could add the function with a download but that it would be there by DEFAULT like several other distributions so it is more informative.

That does not belong in forums, but either in bugzilla as a feature request, or on developers mailing list. Bugzilla is probably better.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron