LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-09-2005, 01:44 PM   #1
Drunkalot
Member
 
Registered: Aug 2004
Distribution: Linux from Scratch
Posts: 69

Rep: Reputation: 15
change the font color


I'm making a script for automating the backup here in the enterprize I work, and I output the log to a file with the echo command...

I need to know how can I change the color of the font, so that when success I write in green and when fail I write in red...

Is that a way to do that???


thx..
 
Old 08-09-2005, 04:18 PM   #2
secesh
Senior Member
 
Registered: Sep 2004
Location: Savannah, GA
Distribution: Ubuntu, Gentoo, Mythbuntu, ClarkConnect
Posts: 1,154

Rep: Reputation: 47
first hit on google:

http://www.linuxvoodoo.com/resources...olorizing.html
 
Old 08-09-2005, 10:37 PM   #3
jayemef
Member
 
Registered: Aug 2005
Location: Juniata College, PA
Distribution: Ubuntu, Slackware
Posts: 67

Rep: Reputation: 15
I keep a file called ansicolor specifically for colorizing terminals (can't remember where I got the idea). It has been particularly useful with setting PS1 variables on the various machines I have to remotely administer. The nice thing about this strategy is that you can define all your color variables once, then simply import the file, whenever needed, with source /path/to/ansicolor. The file is too long to copy the entire thing, but the first portion is below. The rest of the file is exactly the same, only placing these font colors on various colored backgrounds.
Code:
# Colors on DEFAULT background.
C_BLACK="\[\033[0;30m\]"
C_GRAY_BOLD="\[\033[1;30m\]"

C_RED="\[\033[0;31m\]"
C_RED_BOLD="\[\033[1;31m\]"

C_GREEN="\[\033[0;32m\]"
C_GREEN_BOLD="\[\033[1;32m\]"

C_YELLOW="\[\033[0;33m\]"
C_YELLOW_BOLD="\[\033[1;33m\]"

C_BLUE="\[\033[0;34m\]"
C_BLUE_BOLD="\[\033[1;34m\]"

C_PURPLE="\[\033[0;35m\]"
C_PURPLE_BOLD="\[\033[1;35m\]"

C_CYAN="\[\033[0;36m\]"
C_CYAN_BOLD="\[\033[1;36m\]"

C_WHITE="\[\033[0;37m\]"
C_WHITE_BOLD="\[\033[1;37m\]"


# Color reset.
C_RESET="\[\033[0m\]"
And, to put to use (taken from my root .bashrc):
Code:
source /home/jim/bin/ansicolor
PS1="[$C_RED_BOLD\u$C_RESET@\h \W]\\$ "

Last edited by jayemef; 08-09-2005 at 10:40 PM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change font color xterm aeruzcar Linux - Software 3 01-04-2012 04:48 PM
How to change KDE 3.3 Desktop font color ? s34n Linux - Software 6 08-25-2009 12:38 PM
Change font COLOR in window title aeruzcar Linux - General 3 09-14-2005 11:26 PM
change the console font color minike Slackware 3 08-30-2004 05:11 PM
change font color...no NOT in X centr0 Slackware 4 05-01-2003 03:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:02 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