# `simply-colored`
[](https://crates.io/crates/simply_colored)
[](https://docs.rs/simply_colored)


[](https://github.com/nik-rev/simply-colored)
This crate is the simplest yet ergonomic way to add color to your terminal.
```toml
simply_colored = "0.1"
```
All this crate contains is a few dozen `const`ants corresponding to particular ANSI escape codes.
## Usage
```rust
use simply_colored::*;
println!("{BLUE}{BOLD}Simply colored!")
```
### Foreground
|  | `{GREEN}Simply colored!` |  |
|  | `{YELLOW}Simply colored!` |  |
|  | `{RED}Simply colored!` |  |
|  | `{MAGENTA}Simply colored!` |  |
|  | `{BLUE}Simply colored!` |  |
|  | `{CYAN}Simply colored!` |  |
|  | `{WHITE}Simply colored!` |  |
|  | `{BLACK}Simply colored!` |  |
|  | `{DIM_GREEN}Simply colored!` |  |
|  | `{DIM_YELLOW}Simply colored!` |  |
|  | `{DIM_RED}Simply colored!` |  |
|  | `{DIM_MAGENTA}Simply colored!` |  |
|  | `{DIM_BLUE}Simply colored!` |  |
|  | `{DIM_CYAN}Simply colored!` |  |
|  | `{DIM_WHITE}Simply colored!` |  |
|  | `{DIM_BLACK}Simply colored!` |  |
### Background
|  | `{BG_GREEN}Simply colored!` |  |
|  | `{BG_YELLOW}Simply colored!` |  |
|  | `{BG_RED}Simply colored!` |  |
|  | `{BG_MAGENTA}Simply colored!` |  |
|  | `{BG_BLUE}Simply colored!` |  |
|  | `{BG_CYAN}Simply colored!` |  |
|  | `{BG_WHITE}Simply colored!` |  |
|  | `{BG_BLACK}Simply colored!` |  |
|  | `{BG_DIM_GREEN}Simply colored!` |  |
|  | `{BG_DIM_YELLOW}Simply colored!` |  |
|  | `{BG_DIM_RED}Simply colored!` |  |
|  | `{BG_DIM_MAGENTA}Simply colored!` |  |
|  | `{BG_DIM_BLUE}Simply colored!` |  |
|  | `{BG_DIM_CYAN}Simply colored!` |  |
|  | `{BG_DIM_WHITE}Simply colored!` |  |
|  | `{BG_DIM_BLACK}Simply colored!` |  |
### Effects
| *Italic* | `{ITALIC}Simply colored!` |
| **Bold** | `{BOLD}Simply colored!` |
| <u>Underline</u> | `{UNDERLINE}Simply colored!` |
| Blink | `{BLINK}Simply colored!` |
| Reverse | `{REVERSE}Simply colored!` |
| <del>Strikethrough</del> | `{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:
```rust
use anstream::println;
use simply_colored::*;
println!("My number is {GREEN}10{RESET}!");
println!("My number is not {RED}4{RESET}!");
```
## Links
If you want links in the terminal, all you need is:
```rust
fn hyperlink(link: impl core::fmt::Display, text: impl core::fmt::Display) -> String {
format!("\x1b]8;;{link}\x1b\\{text}\x1b]8;;\x1b\\")
}
```
Example usage:
```rust
println!(
"Check out simply_colored on {}!",
hyperlink(
"https://github.com/nik-rev/simply-colored",
"GitHub"
)
);
```