Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eskerda/vtfmt
quick and friendly terminal colors for bash
https://github.com/eskerda/vtfmt
Last synced: 23 days ago
JSON representation
quick and friendly terminal colors for bash
- Host: GitHub
- URL: https://github.com/eskerda/vtfmt
- Owner: eskerda
- License: mit
- Created: 2021-12-14T14:42:56.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-03T09:04:29.000Z (over 2 years ago)
- Last Synced: 2024-10-04T21:38:48.342Z (about 1 month ago)
- Language: Shell
- Size: 2.93 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```bash
#!/usr/bin/env bashsource 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"
```