rrrene/bunt
{ "createdAt": "2015-11-05T21:45:55Z", "defaultBranch": "master", "description": "256 color ANSI coloring in Elixir CLIs", "fullName": "rrrene/bunt", "homepage": null, "language": "Elixir", "name": "bunt", "pushedAt": "2023-12-06T11:00:54Z", "stargazersCount": 117, "topics": [], "updatedAt": "2025-10-23T18:41:02Z", "url": "https://github.com/rrrene/bunt"}
Enables 256 color ANSI coloring in the terminal and gives you the ability to alias colors to more semantic and application-specfic names.
Installation
Section titled “Installation”It’s available via Hex:
-
Add bunt to your list of dependencies in
mix.exs:def deps do [{:bunt, ”~> 1.0”}] end
-
Ensure bunt is started before your application:
def application do [extra_applications: [:bunt]] end
256 colors
Section titled “256 colors”
IO.ANSI provides an interface to write text to the terminal in eight different colors like this:
["Hello, ", :red, :bright, "world!"]|> IO.ANSI.format|> IO.putsThis will put the word “world!” in bright red.
To cause as little friction as possible, the interface of Bunt.ANSI is 100% adapted from IO.ANSI.
We can use Bunt in the same way:
["Hello, ", :color202, :bright, "world!"]|> Bunt.ANSI.format|> IO.putswhich puts a bright orange-red "world!" on the screen.
Bunt also provides a shortcut so we can skip the format call.
["Hello, ", :color202, :bright, "world!"]|> Bunt.putsand since nobody can remember that :color202 is basically :orangered, you can use :orangered directly.
Named colors
Section titled “Named colors”The following colors were given names, so you can use them in style:
[:gold, "Look, it's really gold text!"]|> Bunt.putsReplace :gold with any of these values:
darkblue mediumblue darkgreen darkslategray darkcyandeepskyblue springgreen aqua dimgray steelbluedarkred darkmagenta olive chartreuse aquamarinegreenyellow chocolate goldenrod lightgray beigelightcyan fuchsia orangered hotpink darkorangecoral orange gold khaki moccasinmistyrose lightyellowYou can see all supported colors by cloning the repo and running:
$ mix run script/colors.exsUser-defined color aliases
Section titled “User-defined color aliases”But since all these colors are hard to remember, you can alias them in your config.exs:
# I tend to start the names of my color aliases with an underscore# but this is, naturally, not a must.
config :bunt, color_aliases: [_cupcake: :color205]Then you can use these keys instead of the standard colors in your code:
[:_cupcake, "Hello World!"]|> Bunt.putsUse this to give your colors semantics. They get easier to change later that way. (A colleague of mine shouted “It’s CSS for console applications!” when he saw this and although that is … well, not true, I really like the sentiment! :+1:)
Contributing
Section titled “Contributing”- Fork it!
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Author
Section titled “Author”René Föhring (@rrrene)
License
Section titled “License”Bunt is released under the MIT License. See the LICENSE file for further details.
“Elixir” and the Elixir logo are copyright (c) 2012 Plataformatec.
Elixir source code is released under Apache 2 License.
Check NOTICE, ELIXIR-LICENSE and LICENSE files for more information.