All Projects → mackwic → Colored

mackwic / Colored

Licence: mpl-2.0
(Rust) Coloring terminal so simple you already know how to do it !

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Colored

Colorette
Easily set the color and style of text in the terminal.
Stars: ✭ 1,047 (+46.43%)
Mutual labels:  terminal, colors
Purify
🌈 Clean & vibrant color schemes for Vim, Terminals...
Stars: ✭ 142 (-80.14%)
Mutual labels:  terminal, colors
Colors
List of 256 color codes for Xterm including an example of the color, Xterm Name, Xterm Number, HEX, RGB and HSL code.
Stars: ✭ 73 (-89.79%)
Mutual labels:  terminal, colors
Git Praise
A nicer git blame.
Stars: ✭ 24 (-96.64%)
Mutual labels:  terminal, colors
Colorful
Terminal string styling done right, in Python 🐍 🎉
Stars: ✭ 456 (-36.22%)
Mutual labels:  terminal, colors
Nord Hyper
An arctic, north-bluish clean and elegant Hyper theme plugin.
Stars: ✭ 96 (-86.57%)
Mutual labels:  terminal, colors
Nord Termite
An arctic, north-bluish clean and elegant Termite color theme.
Stars: ✭ 104 (-85.45%)
Mutual labels:  terminal, colors
Terminalizer
🦄 Record your terminal and generate animated gif images or share a web player
Stars: ✭ 12,165 (+1601.4%)
Mutual labels:  terminal, colors
Nord Dircolors
An arctic, north-bluish clean and elegant dircolors theme.
Stars: ✭ 328 (-54.13%)
Mutual labels:  terminal, colors
Pastel
A command-line tool to generate, analyze, convert and manipulate colors
Stars: ✭ 3,742 (+423.36%)
Mutual labels:  terminal, colors
Termenv
Advanced ANSI style & color support for your terminal applications
Stars: ✭ 555 (-22.38%)
Mutual labels:  terminal, colors
Termcolor
Termcolor is a header-only C++ library for printing colored messages to the terminal. Written just for fun with a help of the Force.
Stars: ✭ 533 (-25.45%)
Mutual labels:  terminal, colors
Tml
🌈💻🎨 A tiny markup language for terminal output. Makes formatting output in CLI apps easier!
Stars: ✭ 634 (-11.33%)
Mutual labels:  terminal, colors
Gogh
Color Scheme for Gnome Terminal and Pantheon Terminal
Stars: ✭ 6,503 (+809.51%)
Mutual labels:  terminal
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+4328.53%)
Mutual labels:  terminal
Ruby jard
Just Another Ruby Debugger. Provide a rich Terminal UI that visualizes everything your need, navigates your program with pleasure, stops at matter places only, reduces manual and mental efforts. You can now focus on real debugging.
Stars: ✭ 669 (-6.43%)
Mutual labels:  terminal
Epr
CLI Epub Reader
Stars: ✭ 657 (-8.11%)
Mutual labels:  terminal
Flowing Gradient
Android Library to make a flowing gradient effect, similar to that used in Instagram Android login screen
Stars: ✭ 701 (-1.96%)
Mutual labels:  colors
Cheat.sh
the only cheat sheet you need
Stars: ✭ 27,798 (+3787.83%)
Mutual labels:  terminal
Nord Iterm2
An arctic, north-bluish clean and elegant iTerm2 color scheme.
Stars: ✭ 651 (-8.95%)
Mutual labels:  terminal

Colored

Build Status Crates.io Crates.io

Coloring terminal so simple, you already know how to do it!

    "this is blue".blue();
    "this is red".red();
    "this is red on blue".red().on_blue();
    "this is also red on blue".on_blue().red();
    "you can use truecolor values too!".truecolor(0, 255, 136);
    "background truecolor also works :)".on_truecolor(135, 28, 167);
    "bright colors are welcome as well".on_bright_blue().bright_red();
    "you can also make bold comments".bold();
    println!("{} {} {}", "or use".cyan(), "any".italic().yellow(), "string type".cyan());
    "or change advice. This is red".yellow().blue().red();
    "or clear things up. This is default color and style".red().bold().clear();
    "purple and magenta are the same".purple().magenta();
    "and so are normal and clear".normal().clear();
    "you can specify color by string".color("blue").on_color("red");
    String::from("this also works!").green().bold();
    format!("{:30}", "format works as expected. This will be padded".blue());
    format!("{:.3}", "and this will be green but truncated to 3 chars".green());

How to use

Add this in your Cargo.toml:

[dependencies]
colored = "2"

and add this to your lib.rs or main.rs:

    extern crate colored; // not needed in Rust 2018

    use colored::*;

    // test the example with `cargo run --example most_simple`
    fn main() {
        // TADAA!
        println!("{} {} !", "it".green(), "works".blue().bold());
    }

Features

  • Safe rust, easy to use, minimal dependencies, complete test suite
  • Respect the CLICOLOR/CLICOLOR_FORCE behavior (see the specs)
  • Respect the NO_COLOR behavior (see the specs)
  • Works on Linux, MacOS, and Windows (Powershell)

Colors:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta (or purple)
  • cyan
  • white

Bright colors: prepend the color by bright_. So easy. Background colors: prepend the color by on_. Simple as that. Bright Background colors: prepend the color by on_bright_. Not hard at all.

Truecolors

Colored has support for truecolors where you can specify any arbitrary rgb value.

This feature will only work correctly in terminals which support true colors (i.e. most modern terminals).

You can check if your terminal supports true color by checking the value of the environment variable $COLORTERM on your terminal. A value of truecolor or 24bit indicates that it will work.

Styles:

  • bold
  • underline
  • italic
  • dimmed
  • reversed
  • blink
  • hidden
  • strikethrough

You can clear color and style anytime by using normal() or clear()

Advanced Control:

Dynamic color from str

As Color implements FromStr, From<&str>, and From<String>, you can easily cast a string into a color like that:

// the easy way
"blue string yo".color("blue");

// this will default to white
"white string".color("zorglub");

// the safer way via a Result
let color_res : Result<Color, ()> = "zorglub".parse();
"red string".color(color_res.unwrap_or(Color::Red));
Colorization control

If you want to disable any coloring at compile time, you can simply do so by using the no-color feature.

For example, you can do this in your Cargo.toml to disable color in tests:

[features]
# this effectively enable the feature `no-color` of colored when testing with
# `cargo test --feature dumb_terminal`
dumb_terminal = ["colored/no-color"]

You can use have even finer control by using the colored::control::set_override method.

Build with Docker

Install Docker

Use the install instructions located here

Build the Docker image

docker build -t colored_image .

Build the library

docker run --rm -it -v "$PWD":/src -u `id -u`:`id -g` colored_image /bin/bash -c "cargo build"

Test the library

docker run --rm -it -v "$PWD":/src -u `id -u`:`id -g` colored_image /bin/bash -c "cargo test"

Todo

  • More tests ?: We always welcome more tests! Please contribute!

Credits

This library wouldn't have been the same without the marvelous ruby gem colored.

Thanks for the ansi_term crate for providing a reference implementation, which greatly helped making this crate output correct strings.

License

Mozilla Public License 2.0. See the LICENSE file at the root of the repository.

In non legal terms it means that:

  • if you fix a bug, you MUST give me the code of the fix (it's only fair)
  • if you change/extend the API, you MUST give me the code you changed in the files under MPL2.
  • you CAN'T sue me for anything about this code
  • apart from that, you can do almost whatever you want. See the LICENSE file for details.

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].