+ Reply to Thread
Results 1 to 4 of 4

Thread: Colored text

  1. #1
    DarkLordoftheMonkeys's Avatar
    DarkLordoftheMonkeys is offline Programming Professional
    Join Date
    Oct 2009
    Location
    Massachussets
    Posts
    255
    Blog Entries
    56
    Rep Power
    11

    Colored text

    Not sure if this will work on other people's computers. On my system (Mac OS X) it displays text in red and blue.

    Code:
    #!/bin/bash
    echo "This text is colored red." | grep --color=always "This text is colored red.";
    #displays text in red
    mkdir "longfilethatiwillneveruse";
    cd "longfilethatiwillneveruse";
    mkdir "This text is colored blue.";
    ls -G;
    #displays text in blue
    rmdir "This text is colored blue.";
    cd ..;
    rmdir "longfilethatiwillneveruse";
    Kind of useless by itself, but if I want to display a message in a shell script, color coding it makes it a hell of a lot easier to read.
    Life's too short to be cool. Be a nerd.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2008
    Location
    Somewhere that is shorter to write than "In the gloomy shadows of my personal namespace"
    Posts
    10,725
    Blog Entries
    2
    Rep Power
    90

    Re: Colored text

    You can also set colors (and more) using escape sequences (echo -e) - just a tip
    Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

  4. #3
    TkTech's Avatar
    TkTech is offline The Crazy One
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,412
    Blog Entries
    1
    Rep Power
    31

    Re: Colored text

    Most unix's (ala linux) support ANSI Colors/VT100. Pedigree supports it too. Lookup 'VT100 Escape codes' to see all the neat things you can do with them.

    (Works on windows too, if you load ANSI.sys (I think that's the one, haven't done it in forever))

  5. #4
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Colored text

    Yes, you're right, Tk. I wrote a short tutorial about this, actually. Shell Script GUIs or something stupid like that.
    sudo rm -rf /

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Colored post frame in phpbb3
    By HappyWarrior in forum PHP Development
    Replies: 2
    Last Post: 07-05-2011, 08:58 PM
  2. Replies: 0
    Last Post: 10-10-2010, 11:06 AM
  3. How to save the text in a text file ???
    By kresh7 in forum Visual Basic Programming
    Replies: 1
    Last Post: 04-11-2010, 02:03 AM
  4. Replies: 0
    Last Post: 02-11-2009, 10:38 PM
  5. Colored Members
    By diplomat in forum Announcements
    Replies: 2
    Last Post: 07-26-2006, 06:17 PM

Tags for this Thread

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