Colored prompt?


Silent-Hunter

Hardcore Member
Joined
May 29, 2010
Messages
3,485
How do I get a colored command prompt like I have on my Gentoo machine, with green for normal user and red for root? Can I just copy the /etc/bash.bashrc file, or do I have to do something special for the Pandora?
 
just edit your bashrc for root and your user google how to use bash/shell colors and do it :)

you can also use user-made applications like oh-my-zsh for zsh-shell; i'm sure there is something similar for bash too (you can use zsh instead of bash too)
 
Last edited by a moderator:
OK. I was just worried it might screw it up. The instructions I found were wpecifically for Arch Linux, so I wasn't sure.
 
OK, I made my regular prompt colored, but when I switch to root, I want it a different color. So I made a second .bashrc file in my /home/root folder, but it won't listen to that one when I become root.
 
How are you becoming root? On this machine here (haven't my Pandora handy) it seems the .bashrc file gets sourced whether you do a quick 'su' or a proper 'su -' login session. Hell, even a hacky 'sudo su' seems to be reading my root .bashrc too!
 
There is no such place as /home/root.

The home folder of root is /root, so you have to put your .bashrc there.

How are you becoming root? On this machine here (haven't my Pandora handy) it seems the .bashrc file gets sourced whether you do a quick 'su' or a proper 'su -' login session. Hell, even a hacky 'sudo su' seems to be reading my root .bashrc too!
@Levi,

Eh, what?
 
Last edited by a moderator:
Sorry, I hadn't noticed the '/home/root' typo there.


When I started writing that post I was convinced a non-login session didn't read .bashrc, but having tested it, it seems it just works . I had to edit that post a number of times before I hit submit, so it's likely it doesn't make the most sense.
 
For me, on my pandora, it IS /home/root and even wehn doing su bash ignores /home/root/.bashrc on the Pandora. If I can't get it to work it's not that big a deal, but I'm sure there's gotta be a way to do it.

EDIT: Apparently, when I do "su -" it gives me an uncoloured prompt "~ # " when done from my home folder.
 
Last edited by a moderator:
Yes, it would appear you're correct. How unusual - I also have a /home/root directory and no /root directory.


The uncouloured prompt is because when you do a 'su -' it's spawning a new instance of /bin/sh, which on the Pandora is actually a link to busybox. Busybox is a single executable that similates shell, copy, cd and other commonly used commands - it's quite common on embedded linux. It appears that busybox most closely emulates ash, judging by the file traces it leaves in /home/root (most notable a .ash_history file)


You can change this by doing issuing a chsh command. Issue it on its own as root and it'll interactively take you through the setting - use /bin/bash and next time you do a 'su -' it'll read any .bashrc in /home/root and apply those prompt settings. No idea if that's the best way to do it on Pandora, but personally I don't see the need to use busybox on a machine like the Pandora.
 
Last edited by a moderator:
Back
Top