Skip to content

eskerda/vtfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

vtfmt: quick and friendly terminal colors for bash

vtfmt is yet another helper to output ANSI escape codes for colors/graphic mode on terminals. It can both be used as a standalone tool or directly sourced from your bash scripts.

Usage

#!/usr/bin/env bash

source vtfmt

# direct output
echo -en "$(vtfmt bg:light-magenta fg:black bold) vtfmt $(vtfmt reset) "
echo -e "This utility is by no means $(vtfmt fg:green)feature $(vtfmt underline)complete.$(vtfmt reset) "
echo -e "And yet it can do quite some things considering how $(vtfmt bold)small$(vtfmt normal) it is!"
echo ""
declare -f vtfmt
echo ""

# or basically anywhere to compose different color modes
WARN_C="$(vtfmt bg:yellow fg:black) WARN $(vtfmt reverse) %s$(vtfmt reset)\n"
INF_C="$(vtfmt bg:green fg:black) INFO $(vtfmt reverse) %s$(vtfmt reset)\n"
ERR_C="$(vtfmt bg:red fg:black)  ERR $(vtfmt reverse) %s$(vtfmt reset)\n"

function inf  { printf "$INF_C" "$*" ; }
function err  { printf "$ERR_C" "$*" ; }
function warn { printf "$WARN_C" "$*" ; }

inf "some info"
warn "you have been warned"
err "such an error"

About

quick and friendly terminal colors for bash

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages