Git Product home page Git Product logo

totty's Introduction

totty

totty unclogs pipes and gets them flowing again.

The standard I/O functions in libc will detect when a program is not writing to a terminal (also called a tty) and will automatically buffer output. While this is good for performance it can break the interactivity of a piped command that you're watching at the terminal.

Add the word totty (as in, "to a terminal") before any command in your pipe and that command will believe it is writing to a terminal, disabling the automatic buffering feature.

An example

A common command is:

tail -f /var/log/apache2/access.log | grep 404

but if a second grep is added, the output stops until the buffer fills:

tail -f /var/log/apache2/access.log | grep 404 | grep favicon.ico

To fix this, use totty and the pipe flows again!

tail -f /var/log/apache2/access.log | totty grep 404 | grep favicon.ico

No need to figure out which component is the source of the clog! It's safe to add it everywhere:

totty tail -f /var/log/apache2/access.log | totty grep 404 | totty grep favicon.ico

Alternatives

You may see suggestions to use the script command with particular flags for this purpose: script --return -c "command to execute" /dev/null. This has several downsides:

  • it can be hard to remember the exact invocation
  • it requires you to quote/escape the command to invoke
  • it is not portable (none of the flags are supported on macOS)
  • it's long and ugly

By comparison, totty works anywhere that supports POSIX pseudo-terminals, is easy to remember, is easy to introduce to a working pipe, and requires no escaping or modification of the pipe component that you're unclogging.

totty's People

Contributors

syncsynchalt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.