Jump to content

Colored text

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
DarkLordoftheMonkeys

DarkLordoftheMonkeys

    Programming Professional

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


#!/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
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
You can also set colors (and more) using escape sequences (echo -e) - just a tip ;)
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#3
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
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))

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

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