lscolors

package
v12.60.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package lscolors provides methods for colorizing file names based on colors from dircolors

Index

Examples

Constants

View Source
const RESET_SEQ = "\033[0m"

RESET_SEQ is ANSI reset sequence

Variables

This section is empty.

Functions

func Colorize

func Colorize(file string) string

Colorize return file name with ANSI control sequences

Example
file := "myfile.txt"
fmt.Println(Colorize(file))
Output:

func ColorizePath added in v12.46.0

func ColorizePath(fullPath string) string

Colorize return path with ANSI control sequences

Example
path := "/home/john/myfile.txt"
fmt.Println(ColorizePath(path))
Output:

func GetColor added in v12.46.0

func GetColor(file string) string

GetColor returns ANSI control sequence with color for given file

Example
file := "myfile.txt"
dir := "/home/john"

colorSeq := GetColor(file)

fmt.Printf(
	"%s/"+colorSeq+"%s"+RESET_SEQ+"\n",
	dir, file,
)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL