Last active
August 20, 2022 08:05
-
-
Save nathants/f6d3f2cd4147af102c65a69a7e729b53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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