Skip to content

Repository files navigation

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

About

Convert text containing ANSI control codes into plain ASCII text.

Resources

Stars

27 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages