GithubHelp home page GithubHelp logo

jmoudrik / txtstyle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from armandino/txtstyle

0.0 1.0 0.0 76 KB

Command-line tool for colorizing log files based on regular expressions (requires Python 2.x)

License: Apache License 2.0

Shell 4.93% Python 95.07%

txtstyle's Introduction

TxtStyle

TxtStyle is a command line tool colorizing output of console programs. It makes it easier to visually scan log files. Or it can be simply used to make output prettier.

TxtStyle

Try it out

git clone git://github.com/armandino/TxtStyle.git
cd TxtStyle

Apply 'example' style to example.log

./txts -n example example.log

Color ifconfig output

ifconfig | ./txts -n ifconfig

Color calendar

cal 2012 | ./txts -n calendar

Color ps output

ps aux | txts -n ps

Install

To install, execute the setup script in the TxtsStyle directory:

sudo python2 setup.py install

(Alternatively, simply put the txts script on the PATH)

Define your own styles

TxtStyle reads styles from a conf file under user's home directory:

~/.txts.conf

There are some example styles defined out of the box. To define your own, add styles to the conf and reference them by name.

For example, add "mystyle":

[Style="mystyle"]
blue: index(0-6)
red: regex("foo")
green bold: regex("bar")
grey on-yellow: regex("baz")

TxtStyle works by styling lines of text using regular expressions and/or string indexes. So index(0-6) highlights a substring of a line and regex("pattern") highlights text matching the pattern.

Save the conf file with "mystyle" and run txts with the -n (or --name) option:

echo "Styling foo, bar, and baz." | txts -n mystyle

TxtStyle configuration supports a small set of named color keys (such as red, blue, yellow) and an extended set of numeric keys (from 1 to 255). To print available keys use the -p option:

txts -p

Other usage examples

Highlight text using the -r (or --regex) option. For example

echo "A Foo and a Bar" | txts -r "Foo|Bar"

will color both Foo and Bar in red. If you use the -r option multiple times, each of the specified regexps will have a different color, as in:

echo "A Foo and a Bar" | txts -r Foo -r Bar

You can also specify multiple regexps with the -R (or --regex-rest) option with the very same result:

echo "A Foo and a Bar" | txts -R Foo Bar

TxtStyle does not apply styles if output is piped to another command. To force color if the output is piped, use --color-always option:

ps aux | txts -n ps --color-always | less -R

Print basic help

txts -h

txtstyle's People

Contributors

armandino avatar armanep avatar jmoudrik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.