Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

How to change color when doing echo in tcsh?

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-10-2012
kristinu kristinu is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 5 November 2016, 8:06 PM EDT
Posts: 892
Thanks: 67
Thanked 8 Times in 8 Posts
How to change color when doing echo in tcsh?

Is it possible to change the color when doing an echo?

Example, having the following command print in dark blue.


Code:
echo "Hello"

---------- Post updated at 11:50 AM ---------- Previous update was at 10:25 AM ----------

Just figured out how to do it
Sponsored Links
    #2  
Old Unix and Linux 01-10-2012
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 7 December 2016, 12:24 PM EST
Location: Zürich
Posts: 8,598
Thanks: 343
Thanked 1,093 Times in 949 Posts
It might help others if you said how...
Sponsored Links
    #3  
Old Unix and Linux 01-11-2012
kristinu kristinu is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 5 November 2016, 8:06 PM EDT
Posts: 892
Thanks: 67
Thanked 8 Times in 8 Posts
An example is


Code:
echo "\033[1;31m Hello \033[0m"


The '31' and the '1' are the things you change. The '31' is the color code, and the '1' is where you put whatever you want to color. The rest of it is the same for every color coding; the beginning starts coloring, and the stuff afterwards stops coloring ('0' switches it back to default text color). You can use the following color codes:


Code:
30 - black
31 - red
32 - green
33 - yellow
34 - blue
35 - magenta
36 - cyan
37 - white

You can make a pretty nice prompt with it. Also, you can modify it further by including another control char:


Code:
%{\033[1;31m%}%m%{\033[0m%}


In this case, the '1' will make the following color bold. You can use the following modifiers:


Code:
0 - normal
1 - bold
2 - normal again
3 - background color
4 - underline the text
5 - blinking

You can also specify both a foreground and a background color.


Code:
echo "\033[5;41;1;37m   *** ERROR ***   \033[0m"

The Following User Says Thank You to kristinu For This Useful Post:
Scott (01-11-2012)
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Change color on another terminal lhareigh890 Shell Programming and Scripting 2 03-30-2011 12:20 PM
Color on echo output does not work iga3725 Shell Programming and Scripting 4 09-30-2010 12:37 PM
give some color to a word on echo output iga3725 Shell Programming and Scripting 4 07-15-2010 07:01 AM
tcsh/csh: set prompt in production to color red slashdotweenie Shell Programming and Scripting 1 05-14-2010 09:42 AM
ksh - how to echo something in color and bold jakSun8 Shell Programming and Scripting 4 03-19-2008 02:09 PM



All times are GMT -4. The time now is 07:55 PM.