Adding colors to your motd?
I'd like to format my motd with some colors, how can I do it?
:scratch: Thanks! |
You need to learn about ANSI colour codes. You can find codes in your /etc/DIR_COLOR file.
Then you need to put them in your motd file. You cannot just type them in though...they are non-printing escape sequences. You would do something like this: Code:
[user@box]$ echo -en "\033[1;34m" > /etc/motd Text of your motd file..... The first line puts the beginning escape sequence into the file, in this case...a nice dark blue. BE CAREFUL...as this will overwrite whatever is currently in the file, make sure you back it up first. The second line is the actuall content of your motd file. You can break it up over multiple lines if you want, just press enter to get a new line BEFORE the closing quote. When you are happy with the layout then type the ' " >> /etc/motd ' bit. Notice that you use the >> redirection operator this time as to append to the motd file, so that your escape sequence isn't overwritten. You could also open the motd file in your favorite editor at this point, and type in your message that way...just dont edit the escape sequence, which will look like this: ^[[0;34m then save the file and complete step three... The last line closes the colour escape sequence so everything goes back to normal after reading the file. |
has anyone managed to get the above to work.
When I log in my MOTD is in the correct Color but the the command Line stays in that color as wel. The only way I get it to go back to normal is if I do a more on /etc/motd. This is a bit weird. Has anyone ever seen this before or has anyone managed to add color to there MOTD Flossie Mandrake Linux 9.1 :study: |
I know this post might be a little old to bump up, but I am giving relevant information to this thread -- and I may find myself stumbling upon this page through google (like I did originally) and so may many others stumble upon this page.
So don't delete this thread please. Thanks So here is good information, here os some useful color codes Code:
Code Color |
read the Bash-Prompt-HOWTO, very nice stuff. it explains a lot about those color codes, including background colors, blinking text and such... it's about changing the bash-prompt but there's much info on the escape sequences in there. read the HOWTO here. full color table:
Code:
+------------------------------------------------------------+ Flossie: the echo -en "\033[0m" >> /etc/motd line will reset color info so your prompt should be normal... greetz, .-=~ iluvatar ~=-. |
Flossie: Yeah, I got a colours using the method I explained directly above your post. Don't forget the closing sequence so it goes back to normal!!!
|
All times are GMT -5. The time now is 09:37 AM. |