Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lunixbochs/vtclean
strips terminal escapes from text, can preserve color
https://github.com/lunixbochs/vtclean
Last synced: 21 days ago
JSON representation
strips terminal escapes from text, can preserve color
- Host: GitHub
- URL: https://github.com/lunixbochs/vtclean
- Owner: lunixbochs
- License: mit
- Created: 2015-09-24T10:50:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-30T18:16:46.000Z (over 3 years ago)
- Last Synced: 2024-11-06T02:24:06.206Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 109
- Watchers: 6
- Forks: 19
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - vtclean - Parses plain text from terminal output string (Open source library / Command Line)
README
[![Build Status](https://travis-ci.org/lunixbochs/vtclean.svg?branch=master)](https://travis-ci.org/lunixbochs/vtclean)
vtclean
----Clean up raw terminal output by stripping escape sequences, optionally preserving color.
Get it: `go install github.com/lunixbochs/vtclean/[email protected]`
API:
import "github.com/lunixbochs/vtclean"
vtclean.Clean(line string, color bool) stringCommand line example:
$ echo -e '\x1b[1;32mcolor example
color forced to stop at end of line
backspace is ba\b\bgood
no beeps!\x07\x07' | ./vtclean -colorcolor example
color forced to stop at end of line
backspace is good
no beeps!Go example:
package main
import (
"fmt"
"github.com/lunixbochs/vtclean"
)func main() {
line := vtclean.Clean(
"\033[1;32mcolor, " +
"curs\033[Aor, " +
"backspace\b\b\b\b\b\b\b\b\b\b\b\033[K", false)
fmt.Println(line)
}Output:
color, cursor