Results 1 to 5 of 5

Thread: Anyone know how to output pretty colors?

  1. #1

    Anyone know how to output pretty colors?

    I have a few important messages in my script that i really want to stand out and im trying to figure out how to change the color of the text (a nice bright green or something like that would be great!) I didnt see anything in the man pages for echo or elsewhere. Does anyone know how to do this? Once again, any help you can provide would be great!
    --Morphman

  2. #2

    Re: Anyone know how to output pretty colors?

    NORMAL="echo -en \\033[0;39m"
    SUCCESS="echo -en \\033[1;32m"
    WARNING="echo -en \\033[1;33m"
    FAILURE="echo -en \\033[1;31m"

    it should work if you use this in a bash script ..
    normal = black
    succes = green
    warning = yellow
    failure = red ..
    play with the last characters to get other colors 1;32, 1;22 .. and so on ..

  3. #3

    Re: Anyone know how to output pretty colors?

    uhh..... holy crap? I was hoping for something like "echo -green "text"" hehe, if only linux was so easy...
    So what exactly would i put in my script to go from one line:
    echo Please insert the cd...
    to the next line which would say
    echo CLOSE THE WINDOW THAT OPENS WHEN THE CD IS AUTOMOUNTED!!!!
    in the color green and then switch back to default colors? Thanks for the help so far! Im sorry to be such a newbie....
    --Morphman

  4. #4

    Re: Anyone know how to output pretty colors?

    hmm .. i made a little script to demonstrate how it works :
    Code:
    #!/bin/sh
    NORMAL="echo -en \\033[0;39m"
    GREEN="echo -en \\033[1;32m"
    YELLOW="echo -en \\033[1;33m"
    RED="echo -en \\033[1;31m"
    
    $RED
    echo "CLOSE THE WINDOW THAT OPENS WHEN THE CD IS AUTOMOUNTED"
    $NORMAL # set back to normal
    echo -n "something "
    $YELLOW
    echo "else.."
    
    $NORMAL #dont forget or you terminal will stay in the last used color

  5. #5

    Re: Anyone know how to output pretty colors?

    Now thats more like it! Perfect, thanks a lot man! Woohoo! *does a happy dance*

Similar Threads

  1. Using IPTABLES to block access to samba except certain IPs
    By addicted2linux in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 02-01-2006, 03:02 PM
  2. Definitions of color terminology
    By regix in forum Windows - General Topics
    Replies: 1
    Last Post: 09-17-2005, 10:28 PM
  3. Exporting Visio Diagrams in Other File Formats
    By The Donald in forum Windows - General Topics
    Replies: 1
    Last Post: 07-08-2005, 12:55 PM
  4. Linux console Colors And Other Trick's
    By comtux in forum Linux - General Topics
    Replies: 37
    Last Post: 01-18-2005, 02:24 PM
  5. IPTables stuff
    By tarballed in forum Linux - Software, Applications & Programming
    Replies: 8
    Last Post: 02-18-2003, 10:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •