The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
color,bold charandevu Shell Programming and Scripting 0 04-07-2008 12:24 AM
Vim color mirusnet Shell Programming and Scripting 1 01-06-2008 08:43 AM
Different color in mail shahnazurs Shell Programming and Scripting 1 11-02-2007 01:42 AM
ls color andryk AIX 3 05-14-2004 12:26 AM
Color and Users arn_ch UNIX for Dummies Questions & Answers 5 11-05-2000 11:42 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-24-2008
Registered User
 

Join Date: Apr 2008
Posts: 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Wink COLOR needed

Hey ,

Wanted to know how to change the color of the text in unix, i am using AIX 5.3 ...i am a newbie ..lol..can u tell ?

Luv ya,
kisses
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-24-2008
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 916
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Yes, you can. As it is i once wrote a script function to make that easier, here it is:

Code:
# ------------------------------------------------------------------------------
# f_SetTerminalSequences         set terminal sequences according to TERMCAP db
# ------------------------------------------------------------------------------
# Author.....: Wolf Machowitsch, Quest
# last update: 1998 11 27    by: Konstanze Scholz, IBM
# ------------------------------------------------------------------------------
# Revision history:
# - 0.99   1998 10 21   Original Creation
#                       Setting and resetting the attributes should be
#                       worked on.
#
# - 1.00   1998 11 27   Production Release
#                       elaborated on the documentation and replaced the
#                       TERMCAP sequences to ANSI-esc-Sequences. See note
#                       below.
#
# - 1.10   1998 11 27   Production Release
#                       Added checks for the variables
#                       o ANIMATED  (= bold,blink,underscore,..)
#                       o COLOURED  (= coloured animation)
#                       o COLORED   (same as COLOURED)
#
# ------------------------------------------------------------------------------
# Usage:
#   USAGE:
#      f_SetTerminalSequences( <void> ) ==> <void>
#
#   SYNOPSIS:
#      f_SetTerminalSequences initializes and exports variables to
#      make use of the terminals highlighting capabilities such as
#      different colours, bold/underlined output, etc..
#      f_SetTerminalSequences accepts no parameters and returns no
#      meaningful return codes.
#
#   CAVEAT:
#      This function relies on the TERMCAP database, therefore it
#      cannot be guaranteed that the settings all work correct with
#      any terminal. This holds true especially for IBM systems -
#      Big Mama Blue just can't get the TERMCAP correct.
#
#   NOTE: explanation of colour setting sequences
#      Colours are set via a 3-bit 'status nybble' in which the basic 
#      colours (blue, green, red) are turned on or off by setting their
#      respective bits to 1 or 0. The resulting values are added and
#      converted to a decimal number to give the number of the colour.
#      The following table shows the connection between colour numbers
#      and colours:
#
#                                        dec.  bin.   colour
#    |     |     |                        0 ^= 000 ^= black
#    |     |     |                        1 ^= 001 ^= red
#   blue green  red                       2 ^= 010 ^= green
#    |     |     |                        3 ^= 011 ^= brown (== green+red)
#    |     |     +----  1/0 * (2**0)      4 ^= 100 ^= blue
#    |     +----------  1/0 * (2**1)      5 ^= 101 ^= magenta (== blue+red)
#    +----------------  1/0 * (2**2)      6 ^= 110 ^= cyan (== blue+green)
#                                         7 ^= 111 ^= white(== blue+green+red)
#
#    In case of a (coloured) XTerm, AIXTerm, etc. these colours are added to
#    the windows settings provided to the X11. Therefore 'white' does not
#    necessarily mean a RGB-value of /FF/FF/FF, but a considerably lighter
#    colour than 'black' (i.e. "white added to the basic colour scheme of the
#    underlying term").
#
# Prerequisites:
# -   The FPATH environment variable must be set to use this function.
#
# ------------------------------------------------------------------------------
# Known Bugs:
#    The TERMCAP entries for AIXTerm and XTerm under AIX are crap.
#    Therefore we use the (in theory not so common) ESC-sequences
#    here instead of the term capabilities (I've tried them and
#    commented them out, you are free to retry again.) to get the
#    standout modes. They are left here in comments because *in 
#    theory* this would be the preferable way.
#
#    For the hardboiled EMACS user i have even gone so far as to put
#    folding mode sequences into it. How low can one sink i wonder...
# ------------------------------------------------------------------------------
# ......................(C) 98 Wolf Machowitsch ................................
# ------------------------------------------------------------------------------


f_SetTerminalSequences ()
{

if [ -n "$ANIMATED" -o -n "$COLOURED" -o -n "$COLORED" ] ; then
   # {{{ terminal sequences for bold,italic,...        

   # -------------------------------------- TERMCAP text attributes
   # export _N="$(print $(tput rmso;tput rmul) )"   # switch to normal video
   # export _B="$(print $(tput bold) )"             # switch to bold video
   # export _U="$(print $(tput smul) )"             # switch to underlined video
   # export _F="${ESC}[5m"                          # switch to blinking video
   # export _R="$(print $(tput rev) )"              # switch to reverse video


   # ------------------------------------ text attributes the ANSI way
   typeset ESC=" "                               # ATTENTION! this is a
      					          # quoted ESC-char!!

   export _N="${ESC}[0m"                          # switch to normal video
   export _B="${ESC}[1m"                          # switch to bold video
   export _U="${ESC}[4m"                          # switch to underlined video
   export _F="${ESC}[5m"                          # switch to blinking video
   export _R="${ESC}[7m"                          # switch to reverse video

   # }}}

   if [[ -n "$COLOURED" || -n "$COLORED" ]] ; then
      # {{{ terminal sequences for coloured animation

      # ---------------------------------------------- colours
      export ColBgBlack=$(print $(tput colb0) )   # background colour 0 => black
      export ColBgRed=$(print $(tput colb1) )     # background colour 1 => red
      export ColBgGreen=$(print $(tput colb2) )   # background colour 2 => green
      export ColBgBrown=$(print $(tput colb3) )   # background colour 3 => brown
      export ColBgBlue=$(print $(tput colb4) )    # background colour 4 => blue
      export ColBgMagenta=$(print $(tput colb5) ) # background colour 5 => magenta
      export ColBgCyan=$(print $(tput colb6) )    # background colour 6 => cyan
      export ColBgWhite=$(print $(tput colb7) )   # background colour 7 => white

      export ColFgBlack=$(print $(tput colf0) )   # foreground colour 0 => black
      export ColFgRed=$(print $(tput colf1) )     # foreground colour 1 => red
      export ColFgGreen=$(print $(tput colf2) )   # foreground colour 2 => green
      export ColFgBrown=$(print $(tput colf3) )   # foreground colour 3 => brown
      export ColFgBlue=$(print $(tput colf4) )    # foreground colour 4 => blue
      export ColFgMagenta=$(print $(tput colf5) ) # foreground colour 5 => magenta
      export ColFgCyan=$(print $(tput colf6) )    # foreground colour 6 => cyan
      export ColFgWhite=$(print $(tput colf7) )   # foreground colour 7 => white

      # ---------------------------------------------- compatibility layer
      export _bgd=$ColBgBlack
      export _bgr=$ColBgRed
      export _bgg=$ColBgGreen
      export _bgy=$ColBgBrown
      export _bgb=$ColBgBlue
      export _bgc=$ColBgMagenta                   # these two lines were mixed 
      export _bgm=$ColBgCyan                      # up in the original by TW
      export _bgbg=$ColBgWhite

      export _fgd=$ColFgBlack
      export _fgr=$ColFgRed
      export _fgg=$ColFgGreen
      export _fgy=$ColFgBrown
      export _fgb=$ColFgBlue
      export _fgc=$ColFgMagenta                   # these two lines were mixed 
      export _fgm=$ColFgCyan                      # up in the original by TW
      export _fgbg=$ColFgWhite

   # }}}
   fi

else 
   # {{{ reset all variables containing escape sequences

   export _N="" _B="" _U="" _F="" _R="" 
   export _bgd="" _bgr="" _bgg="" _bgy="" _bgb="" _bgc="" _bgm="" _bgbg=""
   export _fgd="" _fgr="" _fgg="" _fgy="" _fgb="" _fgc="" _fgm="" _fgbg=""

   # }}}
fi   

return 0
}
One thing to keep in mind: the ESC-char does not survive copy&paste. You will have to enter it after saving this to a file. Enter "CTRL-V" in vi to quote the next character, then press the ESC key to enter the escape character.

I hope this helps.

bakunin
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 06:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102