Golang package with functionality to add colors to your logs to the terminal.

colrz

GoDoc Go Report Card

It's a set of funcs and constants to provide basic colors to your terminal app.

How to use

Get it

go get github.com/unnamedxaer/colrz

Use it

package main

import (
	"fmt"

	c "github.com/unnamedxaer/colrz"
)

func main() {
	// with method
	fmt.Print(c.Yellow("\nThe tree is yellow."))

	// with const
	fmt.Printf("\n%sThe tree is red.%s", c.FgRed, c.FgReset)

	// background color
	fmt.Printf("\n%s", c.BlueBg(c.Yellow("The tree is green with blue leafs.")))

	fmt.Printf("\n%s", c.WhiteBg(c.Green("The tree is green and ")+c.Yellow("yellow with white leafs.")))

	fmt.Printf("\n%s", c.Yellow(c.MagentaBg("The tree is yellow ")+c.CyanBg(" with colorful leafs.")))

	fmt.Printf("\n%s%sThe tree is %s yellow with %scolorful leafs.%s%s",
		c.BgMagenta, c.FgYellow, c.BgCyan, c.FgBlack, c.BgReset, c.FgReset)
}

output from above code snippet

  • Use colored text
fmt.Print(c.Red("The tree is red."))

red text

  • Use colored text on colored background
fmt.Printf("\n%s", c.BlueBg(c.Red("The tree is red with blue leafs.")))

red text on blue background color

Persistent coloring

If you set color via constant and do not reset it, then the color will persist for the next prints.

	fmt.Printf("\n%sThe tree is red.", c.FgRed)
	// ... some code
	fmt.Printf("\ndone at %v", time.Now().Local())
	// ... some code maybe more prints
	// restore color to normal
	fmt.Print(c.FgReset)
	fmt.Print("\nThe winter is coming, the leaves have fallen.")

persistent text color

All colors

all colors example

Colors in different terminals

Colors may and will vary slightly depending on the terminals.

cmder colors example

Warning

Not all terminals support this features eg. windows cmd / ps < 7.0

example of terminal not supporting colors

License

MIT. See the LICENSE file for more details.

Owner
Kamil
JavaScript Developer
Kamil
Similar Resources

ReverseSSH - a statically-linked ssh server with reverse shell functionality for CTFs and such

 ReverseSSH - a statically-linked ssh server with reverse shell functionality for CTFs and such

ReverseSSH A statically-linked ssh server with a reverse connection feature for simple yet powerful remote access. Most useful during HackTheBox chall

Jan 5, 2023

Pi-fetch - get a summary of your pi-hole stats from your terminal

pi-fetch get a summary of your pi-hole stats from your terminal _ ___ _ _ ___|_|___| _|___| |_ ___| |_ | . | |___| _| -_| _

Jan 9, 2022

Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.

Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.

Stonks is a terminal based stock visualizer and tracker. Installation Requirements: golang = 1.13 Manual Clone the repo Run make && make install Pack

Dec 16, 2022

Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.

Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.

Minutes is a CLI tool for synchronizing work logs between multiple time trackers, invoicing, and bookkeeping software to make entrepreneurs' daily work easier.

Aug 8, 2022

Generate fake logs in different format

Fake logs This application don't do anything but generating random logs! How to use it Build locally $ git clone https://github.com/saphoooo/fake-logs

Jan 2, 2022

A CLI tool for working with CloudWatch logs. It performs functions that I need at work.

CloudWatch Logs Utility A simple utility for working with CloudWatch Logs. AWS should probably build this themselves, but since they won't, I am here

Dec 31, 2021

Git Add Commit - Commit made easy

 Git Add Commit - Commit made easy

Git Add Commit Commit made easy Installation Download the latest release and put the binary in your $PATH Homebrew: brew tap rawnly/tap brew i

Jul 26, 2022

brewfile-desc add descriptions of formulae to Brewfile.

brewfile-desc brewfile-desc add descriptions of formulae to Brewfile. Usage $ cat path/to/Brewfile tap "golangci/tap" tap "k1low/tap" tap "mas-cli/tap

Dec 13, 2022

Go (golang) package with 70+ configurable terminal spinner/progress indicators.

Go (golang) package with 70+ configurable terminal spinner/progress indicators.

Spinner spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full exa

Dec 26, 2022
🎨 Terminal color rendering library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows.
🎨 Terminal color rendering library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows.

?? Terminal color rendering library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows. GO CLI 控制台颜色渲染工具库,支持16色,256色,RGB色彩渲染输出,使用类似于 Print/Sprintf,兼容并支持 Windows 环境的色彩渲染

Dec 30, 2022
Detects whether a terminal supports colors
Detects whether a terminal supports colors

Termcolor Detects what level of color support your terminal has. This package is heavily inspired by chalk's support-color module. Install go get gith

Nov 27, 2022
Light weight Terminal User Interface (TUI) to pick material colors written by Go.
Light weight Terminal User Interface (TUI) to pick material colors written by Go.

mcpick Light weight Terminal User Interface (TUI) to pick material colors. You do NOT need to take your hands off the keyboard to pick colors. Getting

Dec 27, 2022
A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number)

go-c2dmc A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number). Implemented as

Jul 25, 2022
A simple command line functionality to convert your Kaspersky Password Manager exported file to CSV format

A simple command line functionality to convert your Kaspersky Password Manager exported file to CSV format

Apr 20, 2022
Go-colorful: A library for playing with colors in golang
Go-colorful: A library for playing with colors in golang

go-colorful A library for playing with colors in Go. Supports Go 1.13 onwards. Why? I love games. I make games. I love detail and I get lost in detail

Dec 30, 2022
CLI hex dumper with colors
CLI hex dumper with colors

heksa Hex dumper with colors Features ANSI colors for different byte groups such as Printable: A-Z, a-z, 0-9 Spaces: space, tab, new line Special: 0x0

Sep 27, 2022
Donald Knuth's Algorithm 7.2.2.1M for covering with multiplicities and colors via dancing links

Covering with multiplicities and colors via Dancing Links Go implementation of Donald Knuth's Algorithm 7.2.2.1M for covering with multiplicities and

Dec 14, 2022
Cli app to quicky add gitignore files to your current environment
Cli app to quicky add gitignore files to your current environment

Gitignorer Cli app to quickly add gitignore files to your current environment/projects Usage Make sure golang s installed on your machine. After that

Jul 18, 2022
Todo-cmd: an app you can add your tasks , edit or delete them

TODO CMD APP! ??‍♂️ Table of contents General info Update Requirements set-up usage General info todo-cmd is an app you can add your tasks , edit or d

Dec 13, 2021