ANSI colors for your Erlang
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
include
src
test
.gitignore
.travis.yml
README.md
rebar.config

README.md

erlang-color

Build Status

ANSI colors for your Erlang

Usage:

ANSI standard colors

1> io:format("Hello, this is the ~s color~n", [ color:red("red") ]).

Screenshot 1

1> io:format("Hello, this is on ~s~n", [ color:on_blue("blue blackground") ]).

Screenshot 2

Make sure you use the ~s string type, ~p will escape the ANSI code.

xterm 256 colors

1> io:format("Hello, this color is ~s~n", [ color:rgb([0,1,0], "green") ]).

Screenshot 3

true 24-bit colors

Note: as of this writing, 24-bit colors (ISO-8613-3) are not widely adopted in terminal emulators. Konsole and iTerm2 nighly builds are known to support them.

1> io:format("The solarized template is ~s ~s ~s ~s ~s ~s ~s ~s ~s ~s ~s ~s ~s ~s ~s ~s ~n", [
  color:true("002B36", "base03"), color:true("073642", "base02"), color:true("586E75", "base01"),
  color:true("657B83", "base00"), color:true("839496", "base0"),  color:true("93A1A1", "base1"),
  color:true("EEE8D5", "base2"),  color:true("FDF6E3", "base3"),  color:true("B58900", "yellow"),
  color:true("CB4B16", "orange"), color:true("DC322F", "red"),    color:true("D33682", "magenta"),
  color:true("6C71C4", "violet"), color:true("268BD2", "blue"),   color:true("2AA198", "cyan"),
  color:true("859900", "green")]).

Screenshot 4

The MIT License (MIT)

Copyright (c) 2016 Julian Duque, Evgeni Kolev, Duncan McGreggor

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation nfiles (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.