Sha256: fc64b86a0e25f0fc3fbcbf5896508199122f04890d39e64f4ec9c4b701c5d4e7

Contents?: true

Size: 1.55 KB

Versions: 28

Compression:

Stored size: 1.55 KB

Contents

= colors

Ever wondered how to get colors on your terminal? Now you can and ever so easily. 

First, gotta thank the Passenger folks for the initial implementation of the brilliant idea.

== Usage
  require "colors"
  
  Colors.process("<red>Text</red>")
  
Any of these colors red, green, yellow, blue, purple, sea, white are available.

You can add backgrounds to your color by passing bg= in a tag, for instance:
  
  Colors.process("<blue bg=yellow>Blue text on yellow bg</blue>")
  
Finally, you can bold your text with <b>, for instance:
  
  Colors.process("<b>BOLD</b>")

== Terminal color explanation

Non-printing escape sequences have to be enclosed in \[\033[ and \]. For colour escape sequences, they should also be followed by a lowercase m.

So for instance, if you wanted red text, for example, you would surround your text with:

  \e[1m\e[31mRed text\e[0m\e[37m\e[40m

To see all the colors available on your terminal and as a quick and easy guide, run this in your shell:
  #!/bin/bash

  T='text'   # The test text

  echo -e "\n                 40m     41m     42m     43m\
       44m     45m     46m     47m";

  for FGs in '    m' '   1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \
             '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \
             '  36m' '1;36m' '  37m' '1;37m';
    do FG=${FGs// /}
    echo -en " $FGs \033[$FG  $T  "
    for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
      do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";
    done
    echo;
  done
  echo

== Copyright

Copyright (c) 2009 Ari Lerner. See LICENSE for details.

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.1 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.10 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.11 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.12 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.13 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.14 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.15 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.16 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.17 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.2 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.3 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.4 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.5 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.6 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.7 vendor/gems/colors/README.rdoc
auser-poolparty-1.3.8 vendor/gems/colors/README.rdoc
fairchild-poolparty-1.3.17 vendor/gems/colors/README.rdoc
fairchild-poolparty-1.3.5 vendor/gems/colors/README.rdoc
poolparty-1.3.15 vendor/gems/colors/README.rdoc