LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2003, 01:57 PM   #1
cj2001
LQ Newbie
 
Registered: Sep 2003
Posts: 8

Rep: Reputation: 0
Add Color


I created a menu in Bash Shell under REHAT 8 and I would like to know is there is a way to change the background color and the text color. I want the background to be a very light blue and my text If it is an Add selection to be green and if it is a Delete Selection the text to be red.
 
Old 09-25-2003, 05:02 PM   #2
Saraev
Member
 
Registered: Apr 2002
Location: Los Gatos, CA
Distribution: boring redhat 9
Posts: 163

Rep: Reputation: 30
http://www.tldp.org/LDP/abs/html/colorizing.html

That should get you going.
 
Old 03-31-2004, 09:03 PM   #3
cfaj
Member
 
Registered: Dec 2003
Location: Toronto, Canada
Distribution: Mint, Mandriva
Posts: 221

Rep: Reputation: 31
Code:
black=0
red=1
green=2
yellow=3
blue=4
magenta=5
cyan=6
white=7

tput setab $red
tput setaf $yellow
echo this is a test
To avoid calling tput every time you need to change colour, you can store the strings:

Code:
fg[$black]=`tput setaf $black`
bg[$black]=`tput setab $black`
fg[$red]=`tput setaf $red`
bg[$red]=`tput setab $red`
fg[$green]=`tput setaf $green`
bg[$green]=`tput setab $green`
fg[$yellow]=`tput setaf $yellow`
bg[$yellow]=`tput setab $yellow`
fg[$blue]=`tput setaf $blue`
bg[$blue]=`tput setab $blue`
fg[$magenta]=`tput setaf $magenta`
bg[$magenta]=`tput setab $magenta`
fg[$cyan]=`tput setaf $cyan`
bg[$cyan]=`tput setab $cyan`
fg[$white]=`tput setaf $white`
bg[$white]=`tput setab $white`
Then you can use:

Code:
printf "${fg[$red]}${bg[$yellow]}%-33s\n" "Hello, world"
printf "${fg[$yellow]}${bg[$blue]}%-33s\n" "Goodbye, world"
You can also set other attributes:

Code:
bold=`tput bold`
reverse=`tput rev`
 
  


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
how to add color text in ks.cfg (kickstart) kernel99 Linux - General 0 08-22-2005 03:44 PM
[COLOR=red]ENCORE WIRELESS PCI Card 802.11b [/COLOR] enrique145 Linux - Hardware 3 07-07-2004 03:31 PM
bsetroot -gradient texture -from color -to color patpawlowski Linux - General 3 02-10-2004 02:51 PM
How to add color to ls in Slackware gnome-terminal? Onox Linux - Software 10 06-22-2003 10:26 PM
[COLOR=seagreen]HELP-want to use Kickstart/rh7.2 on a notebook[/COLOR] verbali Linux - Newbie 1 05-13-2002 02:59 PM


All times are GMT -5. The time now is 02:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration