Create a gist now

Instantly share code, notes, and snippets.

cat sixel file with penetrating GNU Screen
% screen
% cat test.png | pngtopnm | pnmquant 256 | ppmtosixel | ./penetrate.py && cat
% cat test.png | sixelconv | ./penetrate.py && cat
#!/usr/bin/env python
from sys import stdin, stdout
while True:
s = stdin.read(512 - 8)
if not s:
break
s = s.replace("\x90", "\x1bP")
s = s.replace("\x9c", "\x1b\x1b\\\x1bP\\")
s = s.replace("\x1b\\", "\x1b\x1b\\\x1bP\\")
stdout.write("\x1bP")
stdout.write(s)
stdout.write("\x1b\\")
stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment