LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-17-2003, 04:53 AM   #1
herc
Member
 
Registered: Jul 2003
Posts: 90

Rep: Reputation: 15
Adding colors to your motd?


I'd like to format my motd with some colors, how can I do it?


Thanks!
 
Old 10-17-2003, 06:16 AM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
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
[user@box]$ echo "Text of your motd file....." >> /etc/motd
[user@box]$ echo -en "\033[0m" >> /etc/motd
If you ran 'cat /etc/motd' this would produce something like:

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.

Last edited by bulliver; 10-17-2003 at 06:33 AM.
 
Old 04-09-2004, 02:28 AM   #3
Flossie
LQ Newbie
 
Registered: Sep 2003
Posts: 26

Rep: Reputation: 15
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
 
Old 05-04-2004, 08:41 AM   #4
jon_k
Member
 
Registered: Jul 2003
Location: Fort Worth, Texas
Distribution: Mepis Linux 2004
Posts: 547

Rep: Reputation: 30
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
-----------------------------
[0;30m       |  black text
[0;31m       |  red
[0;32m       |  green
[0;33m       |  blue
[0;34m       |  purple
[0;35m       |  cyan
[0;36m       |  silver
[0;40m       |  red back.
[0;41m       |  green back.
[0;42m       |  brown back.
[0;43m       |  blue back.
[0;44m       |  purple back.
[0;45m       |  cyan back.
[0;46m       |  silver back.
Additionally good reading about the subject can be found at http://www.linuxgazette.com/node/view/8367
 
Old 05-04-2004, 08:52 AM   #5
iluvatar
Member
 
Registered: Jul 2003
Location: netherlands
Distribution: debian
Posts: 403

Rep: Reputation: 30
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:
+------------------------------------------------------------+
|Black       0;30     Dark Gray     1;30                     |
|Blue        0;34     Light Blue    1;34                     |
|Green       0;32     Light Green   1;32                     |
|Cyan        0;36     Light Cyan    1;36                     |
|Red         0;31     Light Red     1;31                     |
|Purple      0;35     Light Purple  1;35                     |
|Brown       0;33     Yellow        1;33                     |
|Light Gray  0;37     White         1;37                     |
+------------------------------------------------------------+
have fun with this!

Flossie: the echo -en "\033[0m" >> /etc/motd line will reset color info so your prompt should be normal...

greetz,
.-=~ iluvatar ~=-.
 
Old 05-04-2004, 04:56 PM   #6
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
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!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/motd skate Linux - Software 5 05-03-2006 08:44 AM
Motd wizex Slackware 6 09-05-2005 08:27 AM
motd iomari Linux - Software 5 04-03-2005 04:43 AM
motd Master Fox Linux - Software 2 08-25-2004 07:40 AM
Is there any MOTD software available besides /etc/motd? csif Linux - Software 1 04-24-2004 06:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration