ansi2txt

command module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 3 Imported by: 0

README

ansi2txt

GitHub release (latest by date) Build Go Report Card

Command-line tool that converts text containing ANSI control codes into plain ASCII text. It works as a filter, reading from stdin or a file, removing all ANSI codes, and sending the output to stdout.

This repo was inspired by kilobyte/colorized-logs.

Installation

APT (Ubuntu, Debian)
Click to expand
  1. If you don't have it already, install the ca-certificates package

    sudo apt install ca-certificates
    
  2. Add gabe565 apt repository

    echo 'deb [trusted=yes] https://apt.gabe565.com /' | sudo tee /etc/apt/sources.list.d/gabe565.list
    
  3. Update apt repositories

    sudo apt update
    
  4. Install ansi2txt

    sudo apt install ansi2txt
    
RPM (CentOS, RHEL)
Click to expand
  1. If you don't have it already, install the ca-certificates package

    sudo dnf install ca-certificates
    
  2. Add gabe565 rpm repository to /etc/yum.repos.d/gabe565.repo

    [gabe565]
    name=gabe565
    baseurl=https://rpm.gabe565.com
    enabled=1
    gpgcheck=0
    
  3. Install ansi2txt

    sudo dnf install ansi2txt
    
AUR (Arch Linux)
Click to expand

Install ansi2txt-bin with your AUR helper of choice.

Homebrew (macOS, Linux)
Click to expand

Install ansi2txt from gabe565/homebrew-tap:

brew install gabe565/tap/ansi2txt
Manual Installation
Click to expand
  1. Download and run the latest release binary for your system and architecture.
  2. Extract the binary and place it in the desired directory.

Usage

If ansi2txt is run with no arguments, it will read data from stdin, filter control codes, and write to stdout. A filename argument can also be provided to filter the file's contents to stdout.

Examples
  1. Read data from stdin:
    ls --color=always | ansi2txt
    
  2. Read data from a file:
    ansi2txt example.txt
    

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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