Skip to content

Instantly share code, notes, and snippets.

@OpenBagTwo
Last active May 31, 2024 15:43
Show Gist options
  • Save OpenBagTwo/54f209cbe8abbd04b9d5b0b880b6a8a2 to your computer and use it in GitHub Desktop.
Save OpenBagTwo/54f209cbe8abbd04b9d5b0b880b6a8a2 to your computer and use it in GitHub Desktop.
Convert jp2a output so it's compatible with neofetch
"""Simple python script that converts jp2a output into the neofetch format"""
import sys
# edit this line to adjust your palette
palette = (1, 4, 5, 6, 7)
for line in sys.stdin:
converted = line.replace("\x1b[0m", "")
for i in range(1, 8):
if i in palette:
replacement = "${c" + str(palette.index(i) + 1) + "}"
else:
replacement = ""
converted = converted.replace(f"\x1b[3{i}m", replacement)
print(converted[:-1])
@LeviSnoot
Copy link

Thanks so much for this, it's been very useful! I wrote some self-documentation on this and figured some people might find it helpful.

neofetch_ascii.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment