This crate is the simplest yet ergonomic way to add color to your terminal.
All this crate contains is a few dozen constants corresponding to particular ANSI escape codes.
Usage
use simply_colored::*; println!("{BLUE}{BOLD}Simply colored!")
Foreground
Background
Effects
| Effect | Type |
|---|---|
| Italic | {ITALIC}Simply colored! |
| Bold | {BOLD}Simply colored! |
| Underline | {UNDERLINE}Simply colored! |
| Blink | {BLINK}Simply colored! |
| Reverse | {REVERSE}Simply colored! |
{STRIKETHROUGH}Simply colored! |
|
| Dim | {DIM}Simply colored! |
| Hide | {HIDE}Simply colored! |
| Reset all styles | {RESET}Simply colored! |
All effects can be prefixed with NO_ to disable e.g. NO_BOLD.
Remove colors when they are not supported
You can use the anstream crate to remove colors when they aren’t supported:
use anstream::println; use simply_colored::*; println!("My number is {GREEN}10{RESET}!"); println!("My number is not {RED}4{RESET}!");
Extras
These can’t be neatly represented using constants, so they’re not a part of this library. They are included here for your own convenience!
Links
If you want links in the terminal, you can use this:
fn link(text: &str, link: &str) -> String { format!("\x1b]8;;{link}\x1b\\{text}\x1b]8;;\x1b\\") }
Example usage:
let github = link("GitHub", "https://github.com/nik-rev/simply-colored"); println!( "Check out simply_colored on {github}!", );
RGB Colors
If you want arbitrary RGB colors, you can use this:
fn rgb(r: u8, g: u8, b: u8) -> String { format!("\x1b[38;2;{r};{g};{b}m") }
Example usage:
let color = rgb(0xc0, 0xff, 0xee); println!("So very {color}ful{RESET}!");















































