Skip to content

Instantly share code, notes, and snippets.

@nathants
Last active August 20, 2022 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathants/f6d3f2cd4147af102c65a69a7e729b53 to your computer and use it in GitHub Desktop.
Save nathants/f6d3f2cd4147af102c65a69a7e729b53 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
import blessed # pip install blessed
import sys
term = blessed.Terminal()
last = None
count = 1
for line in sys.stdin:
line = line.rstrip()
if line == last:
count += 1
print(term.move_up(2) + term.move_x(0))
else:
last = line
count = 1
if count > 1:
print(line, f'[{count}]', flush=True)
else:
print(line, flush=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment