Last active
May 31, 2024 15:43
-
-
Save OpenBagTwo/54f209cbe8abbd04b9d5b0b880b6a8a2 to your computer and use it in GitHub Desktop.
Convert jp2a output so it's compatible with neofetch
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
"""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]) |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example results:
Input:
Output: