Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi all Can i put coloured value in

Status
Not open for further replies.

vti

Technical User
Feb 26, 2001
189
TR
Hi all
Can i put coloured value in my script.

For example

I have 2 value :
echo "1-Continue"
echo "2-exit"


Is it possible to make different colour to questions and numeral values.



Thanks for helps
 
Yep. But it'll be practically non portable
I hope it works...
Unix was made by and for smart people.
 
I thought it's possible ,maybe something wrong with my explanation.I 'd like to print to term-screen by colour.I don't wanna put color in my script .

thanks

 
..one way to do this is to use "tput" and "terminfo" capabilities, if these are available. terminfo allows for the definition of colour attributes, and tput can access those definitions.

"tic" and "infocmp" are the methods used to compile and discover terminal capabilities.

Here's an example, using BOLD rather then a colour, assuming that smso and rmso have been defined in the terminfo database.

BOLD='tput smso'
NOBOLD='tput rmso'

echo "${BOLD}1 ${NOBOLD} - Option 1"
echo "${BOLD}9 ${NOBOLD} - Exit"

Another (primitive) way is to discover the actual terminal codes for displaying colour and embedding them in a script, but I wouldn't recommend this.
 
A little point:
[tt]
BOLD=[red]`[/red]tput smso[red]`[/red]
NOBOLD=[red]`[/red]tput rmso[red]`[/red]
[/tt]

...


I hope it works...
Unix was made by and for smart people.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top