Kabie/dye
Dyeing your terminal!
{ "createdAt": "2014-12-06T20:37:43Z", "defaultBranch": "master", "description": "Dyeing your terminal!", "fullName": "Kabie/dye", "homepage": null, "language": "Elixir", "name": "dye", "pushedAt": "2024-03-02T18:31:26Z", "stargazersCount": 21, "topics": [ "elixir" ], "updatedAt": "2024-03-02T18:23:05Z", "url": "https://github.com/Kabie/dye"}Note: This lib uses uppercase sigil modifiers. So only works with elixir >= 1.1.0.
use Dye will replaces sigils: ~s and ~S.
iex(1)> use DyeDye
iex(2)> ~s"Red text"r"\e[31mRed text\e[0m"
iex(3)> ~s"Bright red text"R"\e[91mBright red text\e[0m"
iex(4)> ~s"Bright red text with green background"Rg"\e[42;91mBright red text with green background\e[0m"
iex(5)> ~s"Underline"u"\e[4mUnderline\e[0m"
iex(6)> ~s"Underline red text"ur"\e[31;4mUnderline red text\e[0m"
iex(7)> ~s"Underline red text with bright green background"urG"\e[102;31;4mUnderline red text with bright green background\e[0m"Color Modifiers
Section titled “Color Modifiers”$ mix test

The first color modifier will be used as text color. If you only want to set background, you can set text then use I to inverse the color.
d: Defaultk: Blackr: Redg: Greeny: Yellowb: Bluem: Magentac: Cyanw: WhiteK: Bright BlackR: Bright RedG: Bright GreenY: Bright YellowB: Bright BlueM: Bright MagentaC: Bright CyanW: Bright WhiteSpecial Modifiers
Section titled “Special Modifiers”e: Don't reset at the endI: Inverse text and background colorD: Boldi: Italicu: Underlinel: Blink slowL: Blink rapidCall sigil_s/sigil_S directly
Section titled “Call sigil_s/sigil_S directly”The default implementation uses macro, which limits the modifiers can only be char list literal. The following won’t work:
mods = 'Rg'sigil_S(<<"foo">>, mods)To use the function implementation, simply do:
use Dye, func: true