5 ms·
Two months ago I hacked something like that for my blog: curl https://fuse.pl/beton/10print.html # with code highlighting curl https://fuse.pl/beton/c
by bronikowski 4y ago
Two months ago I hacked something like that for my blog:
curl https://fuse.pl/beton/10print.html # with code highlighting
curl https://fuse.pl/beton/cegla.html # just prose
- mdibaiee 4y agothe code highlighting is really cool, well done! pretty sure it's possible to do something like that with jekyll by updating the `highlight` liquid tag to be able to render ascii highlighting in case of raw pages.
- tomrod 4y agoNeat!
- dfbsdfbwe2ef2e 4y agoDamn that looks really polished. How does the server know what characters to send so that my specific command line interprets it in a nice way? Sorry if I'm not being very articulate. EDIT: doesn't work when piping to less.
- bronikowski 4y agoI'd be honest, my approach is "everything is utf-8, right? And every terminal has at least 16 colors at the ready?". It does not degrade gracefully, I checked. It's more of a party trick than something reasonable, but nothing stops you from doing it correctly, it would just be a hassle to serve in a static way (every variation would require a different txt file to be generated and sent). > EDIT: doesn't work when piping to less. try -R
- dfbsdfbwe2ef2e 4y ago> try -R works :-)
- bronikowski 4y agoI'm guessing you're on BSD (or maybe Apple)? Their version requires you to tell less there's a raw data at the input.
- dfbsdfbwe2ef2e 4y agoNo, Debian 11. Fresh install too.
- bronikowski 4y agoVery strange, I could have sworn I've tested in without -R with Debian 11 (I can't check, that laptop broke and my other machines are still at 10). Maybe it's terminal definition or something changed. Terminal emulation is a spooking place full of ancient magic. One of the reasons why I assumed "modern defaults". It would turn "a weekend hack" into a session of misery. ;)
- paulgb 4y ago> EDIT: doesn't work when piping to less. What if you pass '-r' to less? (I can't verify myself because it worked without -r for me)
- ggorlen 4y agoLooks fantastic! I can't read the post, but I think you can simplify the 10 print Python code to while True: print(choice("\\/"), end="") (the `format` call doesn't seem needed and `choice` works on any iterable, including strings of characters). Al Sweigart has a repository of "scroll art" similar to 10 print that might interest you: https://github.com/asweigart/scrollart https://github.com/asweigart/scrollart
- bronikowski 4y agoI wanted to be explicit with my iterables for people who might not know that string is a list of chars. The format() call, I can't tell what I was thinking, probably nothing good. Thanks!