This Rust project called ansi-escape-sequences-cli
provides an executable called ansi
which can be used on the Terminal to easily colorize/style your output.
$ cargo install ansi-escape-sequences-cli
(the binary is just called ansi
!)
$ echo "$(ansi bg-purple)Hello World $(ansi reset)$(ansi red)$(ansi bold)$(ansi underline)Red Warning$(ansi reset)"
test.sh ```bash
reset=$(ansi -e reset) red=$(ansi -e red) echo "Foo=${red}bar" echo "Bar=${reset}foo" ```
In res/zsh-completion/_ansi
is a completion file. Install it for example into
/usr/local/share/zsh/site-functions/
.
1:1 copy of "help"-page
```text
ANSI-ESCAPE-SEQUENCES-CLI ('ansi') @ version 0.1.0
Made by Philipp Schuster phip1611@gmail.com
See - https://crates.io/crates/ansi-escape-sequences-cli or
SYNOPSIS:
ansi red|green|bold|strike|bg-cyan|...
[-n|--new-line] [-e|--no-escape] [-h|--help]
[-s|--escape-style bash|unicode|unicode-rust|hex]
PARAMETERS:
-n: add new line character to output (default: false)
-e: don't ASCII-escape output, i.e. it will return real ASCII value of ESC
instead of \e
-s: only useful if -e
is NOT provided: style of the ASCII string escape format
COMMANDS:
For a full list visit: https://crates.io/crates/ansi-escape-sequences-cli
The most basic ones are all supported. For example:
clear/reset
black
bg-black
red
bg-red
green
bg-green
yellow
bg-yellow
blue
bg-blue
purple
bg-purple
cyan
bg-cyan
white
bg-white
normal
bold
dimmed
italic
underline
blink
hidden (hidden)
strike | strikethrough
ESCAPE STYLES
bash: Bash (and many other tools) support \e
that gets replaced by ASCIIs ESC
code.
hex: Many tools allow hex values in the following notation: \x1b
, i.e. ASCIIs ESC
code.
unicode : Many tools allow unicode values in the following notation: \u001b
, i.e. ASCIIs ESC
code.
unicode-rust: Rust uses unicode in the following form: \u{1b}
, i.e. ASCIIs ESC
code.
```