Skip to content

cforler/color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

color

A small Unix CLI tool that colorizes text from standard input using ANSI terminal escape sequences.

It is designed for use in pipes and shell scripts: color writes the requested ANSI escape sequence to stdout, passes the incoming byte stream through, and resets the terminal color afterwards.

Usage

color [-b] [-i] [-f] <color>

Options

Option Description
-b Bold output
-i High-intensity output
-f Force color output even when stdout is not a TTY (e.g. when piping into a file or another program)
-bi Bold and high-intensity output

Colors

black · red · green · yellow · blue · pink · cyan · white · reset

The special value reset emits an ANSI reset sequence to restore the terminal's default formatting.

Examples

# Red text
echo "Hello, world" | color red

# Bold green text
echo "Success" | color -b green

# High-intensity yellow text
echo "Warning" | color -i yellow

# Bold high-intensity blue text
echo "Information" | color -bi blue

# Bold high-intensity blue, forced even when piped to a file
echo "Information" | color -bif blue > output.txt

# Reset terminal formatting
color reset

Installation

Prerequisites

  • GCC or any C99-compatible compiler
  • GNU Make
  • A terminal with ANSI color support

Build & Install

# Build
make

# Install binary, man pages and bash completion
sudo make install

This installs:

  • color/usr/local/bin/color
  • Man page (English) → /usr/local/share/man/man1/color.1.gz
  • Man page (German) → /usr/local/share/man/de/man1/color.1.gz
  • Bash completion → /usr/local/share/bash-completion/completions/color

Uninstall

sudo make uninstall

Bash Completion

Bash completion is installed automatically via make install. After a new shell session, pressing Tab will suggest available colors and options.

If you want to install the completion script manually without installing the binary:

sudo make install_autocomplete

Man Page

After installation, the man page is available in English and German:

man color       # English
man -L de color # German

Notes

  • By default, color escape sequences are only written when stdout is a TTY. Use -f to force color output even when piping to a file or another program.
  • The tool reads from stdin in blocks and is suitable for streaming use cases.

Author

Christian Forler

Acknowledgments

This README was written by Claude, an AI assistant made by Anthropic.

About

A small Unix CLI tool that colorizes text from standard input using ANSI terminal escape sequences.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors