Skip to content

Perl program that can color output of `tar tvf` similarly to the way ls would

Notifications You must be signed in to change notification settings

msabramo/tarcolor

Repository files navigation

tarcolor

A Perl program that can color the output of tar tvf similarly to the way GNU ls would.

By Marc Abramowitz (http://marc-abramowitz.com)

Build Status

Installation

From the CPAN distribution:

$ cpanm App::TarColor

Download a tarball App-TarColor-<version>.tar.gz from the downloads page.

Or build a tarball from the repository using Dist::Zilla:

$ dzil build

Install from the tarball with cpanm (a.k.a.: App::cpanminus):

$ cpanm App-TarColor-<version>.tar.gz

Or untar the tarball and build it:

$ tar xzf App-TarColor-<version>.tar.gz
$ cd App-TarColor-<version>
$ perl Makefile.PL
$ make && make test

Then install it:

$ make install

If you are installing into a system-wide directory, you may need to run:

$ sudo make install

Usage

You can use tarcolor manually like this:

$ tar tvf some_tarball.tgz | tarcolor

There is also a bundled shell script (for bash and zsh) that makes tar automatically pipe its output through tarcolor:

$ source /usr/local/etc/tarcolor/tarcolorauto.sh
$ tarcolorauto on
$ tar tvf some_tarball.tgz
... colored output ...
$ tarcolorauto off
$ tar tvf some_tarball.tgz
... normal uncolored output ...

Customization

Colors can be customized using the LS_COLORS or TAR_COLORS environment variables:

$ export TAR_COLORS='di=01;34:ln=01;36:ex=01;32:so=01;40:pi=01;40:bd=40;33:cd=40;33:su=0;41:sg=0;46'

The format for LS_COLORS and TAR_COLORS is the same format used by LS_COLORS (used by GNU ls). So if you use GNU ls and have your LS_COLORS set, then tarcolor will use similar colors as ls.

Example

tarcolor screenshot

Tested with

  • Mac OS X 10.6.8 (Snow Leopard)

  • Mac OS X 10.7 (Lion)

  • OpenIndiana b151A

    • GNU tar 1.23 (/usr/gnu/bin/tar or /usr/bin/gtar)
    • Solaris tar (/usr/bin/tar) (Fixed in issue 11).
    • pax -- /usr/bin/pax -v -f
    • Solaris cpio (/usr/bin/cpio) (Fixed in issue 14).
  • CentOS 5.5/Linux 2.6.16.33

  • Fedora 16

  • Ubuntu 11.10

  • Debian 4.4.5-8/Linux version 3.1.9-vs2.3.2.5 (DreamHost VPS)

  • FreeBSD 9.0

  • Windows 7/Cygwin 1.7.11-1

    • GNU tar 1.25
    • bsdtar 2.8.3 -- libarchive 2.8.3
    • GNU cpio 2.11 -- cpio -itv < file.tar
    • bsdcpio 2.8.3 -- libarchive 2.8.3 -- cpio -itv < file.tar
    • atool 0.38.0 -- atool -l file.tar

Future enhancements (patches are welcome!)

  • Send me your ideas (especially with patches!)

About

Perl program that can color output of `tar tvf` similarly to the way ls would

Resources

Stars

Watchers

Forks

Packages

No packages published