Skip to main content

Termill

A command line utility library to print out multiple lines of text and replace them. It's simple to print out a single line and replace it by using a carriage return:

print("foo", end="\r")
print("bar")

but that doesn't work with multiple lines. But by utilising backspace characters and the width of the terminal, you can actually replace multiple lines.

This library is just to handle that, so that you can print out lines, flush them, then print out new lines ontop of the old ones. A simple demo is included (demo.py) that just prints out the current time for 5 seconds.

This was just thrown together as a proof of concept, so it's likely very buggy. This has also only been tested on my MacOS machine, with ZSH. I have no idea if this works anywhere else.

Why not curses?

I wanted to be able to monitor certain things and print out regular updates to the terminal. As far as I could tell (based on very very limited research) I could do that with curses, but it would have to take over the whole terminal.

I want to be able to print out few lines and update them, without having to take over the terminal, the idea being that I can see the history in my terminal right before running whatever is printing out updates.

Usage

import time

from termill import Termill

t = Termill()

t.write("line one")
t.write("line two")
t.write("line three")
t.flush()
time.sleep(1)
t.writelines(["line one has changed", "there will be no line three"])
t.flush()

Demo

demo.gif

Metadata

Release files for termill 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for termill 0.2.0
File Size Uploaded
termill-0.2.0.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for termill 0.2.0
File Interpreter ABI Platform
termill-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.0 kB

Release files / termill-0.2.0.tar.gz

Download URL termill-0.2.0.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
90118a378fe4a37dc148eebbd740ee6fc3943f0e55e09fb6804a1784fef24d6c
BLAKE2b-256 checksum
How to use checksums
639fec36738949315503ac02f51fbd23a9e25bd9b4e83312e5475abc29d1305b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Darwin/19.5.0

Release files / termill-0.2.0-py3-none-any.whl

Download URL termill-0.2.0-py3-none-any.whl
Size 2.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f058c5a399736955913e858518048ed4085614fb693e9cf614f17f6afd871673
BLAKE2b-256 checksum
How to use checksums
92209a45f03ffaa1507dc10718e2f069a6f0401bb02eee65ba72ad08361a020d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.5 Darwin/19.5.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page