Page 1 of 1

Bash/shell prompt in different colors for root and users

PostPosted: Dec 18th, '13, 10:25
by ca-on-adam
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

Re: Purple bash prompt for Mageia

PostPosted: Dec 18th, '13, 14:34
by doktor5000
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.

Re: Purple bash prompt for Mageia

PostPosted: Dec 18th, '13, 14:58
by isadora
Thanks doktor5000, works like a charm, out-of-the-box. :)

A simple, informative change...

PostPosted: Mar 5th, '14, 19:37
by zxr250cc
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

Re: A simple, informative change...

PostPosted: Mar 5th, '14, 20:01
by jkerr82508
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

Re: A simple, informative change...

PostPosted: Mar 5th, '14, 20:02
by isadora
Try installing colorprompt from repositories.

edit: you were to fast for me jim ;)

Re: A simple, informative change...

PostPosted: Mar 6th, '14, 02:22
by doktor5000
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.

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

PostPosted: Mar 8th, '14, 05:08
by jiml8
*I* dare to be different! I use a yellow prompt for root, not red. Though most of my Linux VMs use red, by default...

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

PostPosted: Mar 9th, '14, 15:57
by zxr250cc
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

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

PostPosted: Mar 9th, '14, 21:30
by doktor5000
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.