Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to change color when doing echo in tcsh? Post 302589249 by kristinu on Wednesday 11th of January 2012 05:46:40 AM
Old 01-11-2012
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"

This User Gave Thanks to kristinu For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Font Color Change Using .profile

Does anyone know how can I change font color, background color etc for a particular user using .profile? Any help is appreciated. (0 Replies)
Discussion started by: fifo_vs_lifo23
0 Replies

2. UNIX for Dummies Questions & Answers

How to change the font or color of text

Hi Gurus, I have a small requirement where i want to change the color & font of some text in a file. i have a file error.txt which will be created in the script using egrep. After that iam adding these lines at head & tail to that file using the following code awk 'BEGIN{print"Please... (4 Replies)
Discussion started by: pssandeep
4 Replies

3. Shell Programming and Scripting

ksh - how to echo something in color and bold

Hi all, I was to echo Hi in Red and Bold ; and echo There is in Green and bold I got bold to working using tput bold but i am having hard time getting the color. Any help is appreciated, jak (4 Replies)
Discussion started by: jakSun8
4 Replies

4. Shell Programming and Scripting

tcsh/csh: set prompt in production to color red

Hi folks This is our prompt at the moment oracle@pinkipinki:/opt/oracle> grep 'set prompt' .cshrc set prompt = "$user@`uname -n`:$cwd> " We wish to have in production the same prompt, but red. Howto do that? I tried a lot a internet manuals, but it doesn't work. (1 Reply)
Discussion started by: slashdotweenie
1 Replies

5. Shell Programming and Scripting

give some color to a word on echo output

Hi Supposed this text output: How can I show $HOSTNAME in other color than blank? :-) KSH on AIX (4 Replies)
Discussion started by: iga3725
4 Replies

6. Shell Programming and Scripting

Color on echo output does not work

Hi, When I run: echo "\033I see hi in color, but if I run this color is not shown, why? (echo "\033Thanks Israel. ---------- Post updated at 05:17 AM ---------- Previous update was at 04:43 AM ---------- DONE!! I had to run more -v. Thanks (4 Replies)
Discussion started by: iga3725
4 Replies

7. Shell Programming and Scripting

Change color on another terminal

i already have a running and working script for remote connection. is there a way to change the terminal color everytime I ssh remotely to another server? this is to avoid confusion since I will be using only one server to remotely access around 50 servers (solaris, linux,. etc) (2 Replies)
Discussion started by: lhareigh890
2 Replies

8. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here. I have following script (called out_to_streams.csh): #!/bin/tcsh -f echo Redirected to STDOUT > /dev/stdout echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies

9. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

10. UNIX for Beginners Questions & Answers

Change text color from echo command?

I have a bash script that starts and stops a game among other things through in.fifo and out.fifo In game the text comes out gray . Kinda hard to see in game window . I would like to change it to purple and maybe capitalize it. #!/bin/bash #nwservctl.sh cd... (5 Replies)
Discussion started by: 222222quick
5 Replies
setcolor(1F)							   FMLI Commands						      setcolor(1F)

NAME
setcolor - redefine or create a color SYNOPSIS
setcolor color red_level green_level blue_level DESCRIPTION
The setcolor command takes four arguments: color, which must be a string naming the color; and the arguments red_level, green_level, and blue_level, which must be integer values defining, respectively, the intensity of the red, green, and blue components of color. Intensities must be in the range of 0 to 1000. If you are redefining an existing color, you must use its current name (default color names are: black, blue, green, cyan, red, magenta, yellow, and white). setcolor returns the color's name string. EXAMPLES
Example 1 A sample output of setcolor command. The following is an example of the arguments that setcolor takes: `setcolor blue 100 24 300` BUILT-IN FMLI ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.11 5 Jul 1990 setcolor(1F)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy