ls
is overI'm sure many people just type ls
when they touch the terminal, but it's a well-known fact that this is just a waste of time, and you should use your time more meaningfully.
There is nothing that you can benefit from looking at a list of files you know.
So I made a more useful lo
command than ls
.
As the name implies, it is a more useful command than ls
, which gets the latest COMIC LO title and outputs it in a glossy pink color.
Can be used instead of ping
()
Place the following python script as lo
in a location that is in your PATH.
#! /usr/bin/env python3
from urllib.request import urlopen
import re
with urlopen("http://www.akaneshinsha.co.jp/category/item/itemgenre/itemad/magazine-ad/comic-lo/") as res:
html = res.read().decode("utf-8")
urlprefix = "http://www.akaneshinsha.co.jp/item/"
founds = re.findall(r'<a href="{}(\d+?)/?".+?>'.format(urlprefix), html)
if not founds:
quit()
with urlopen(urlprefix + founds[0]) as res:
html = res.read().decode("utf-8").replace("\n", " ")
founds = re.findall(
r'<div class="freetxt">\s*<p>.+?</p>\s*<p>(.+?)</p>', html)
if not founds:
quit()
founds = re.findall(r'「(.+?)」', founds[0])
color = 202
for i, found in enumerate(founds):
print('\033[38;5;%dm%s\033[0m' % (color, found))
if (i + 1) % (max(4, len(founds)) // 4) == 0:
color += 1
COMIC LO is god
TODO I want to add the -l -a -h option
Recommended Posts