跳到正文

个人记录

【Shell】 xbqg

ForkΨKillet约 6 分钟
原文
文章信息与版本

文章信息

发布
2020年8月28日
收录
2026年4月24日
更新
2026年11月14日
篇幅
约 6 分钟

版本

  1. v2当前
  2. v1

简介

bash 下从 新/笔/趣/阁 看网文的脚本。


代码

  1. main.sh
  2. storage.sh

随时更新


如何食用

PS1=">" (以下 > 是命令提示符)

Bash
> ls # 先得到这两个文件,若不需要存储阅读信息,只要前者即可
main.sh         storage.sh

> . main.sh # 用 source(.) 命令加载

> xbqg # 查看帮助
(...)

> xbqg 15_15338/8549128
# 阅读《诡密之主》第1章
# (你可以在 新/笔/趣/阁 网站 URL 中找到需要的 page-id)
# 首先会看到 `curl` 信息,分割线后是标题,随后正文,
# 又一道分割线后是 page-id 信息。
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15131  100 15131    0     0  16925      0 --:--:-- --:--:-- --:--:-- 16906
----------==========----------
第一章 绯红 @ 诡秘之主
----------==========----------
    痛!

    好痛!

    头好痛!

    (...)

----------==========----------


prevpage="15_15338/"
nextpage="15_15338/8549129"
index="15_15338/"

> xbqg ] # 看下一章,而不必手动 xbqg 15_15338/8549129

> clear # 出于种种原因,你清屏了,然而你还没读完第2章,page-id 也不记得了。

> xbqg = # 不用担心,重新加载本章

> xbqg [ # 看前一章,读《诡密》可不能粗心,获许会漏掉重要的线索!(笑)

> date # 要去睡了,但是关机(关掉终端)后 page-id 信息就会消失!
Fri Aug 28 22:22:22 UTC 2020

> touch data # 创建数据文件(名称随意)

> . storage.sh # 加载存储脚本

> xbqg.storage -s /path/to/main.sh /path/to/data
# 需要用绝对路径!
Succeed, please run:
. /path/to/main.sh

> . main.sh # 听话

> xbqg = # 调用一次,写入数据

> cat data # 查看数据,OK
#!/bin/bash
xbqg_prev=81_81336/742962
xbqg_next=81_81336/743435
xbqg_cur=81_81336/743148

> shutdown

> xbqg = # 可以接着看啦!

TodoList

  1. 显示 page-id 信息 (DONE)
  2. 翻页! (DONE)
  3. 存储阅读进度! (DONE)
  4. 章节标题与书名 (DONE)
  5. 差询小说信息(包括目录)(WAIT)

更新日志

  1. 2020.08.25 17:03; Better newlines, especially in the novel text. (I learned how to use echo -e :)
  2. 2020.08.25 18:10; Clear screen before outputing now. So users can scroll to the top easily, and don’t need to locate the text any longer! (printf "\033c" is establer than clear! Because bash told me clear: command not found in recovery mode :)
  3. 2020.08.25 20:09; Better page-id style & formatted code (script edition) supported.
  4. 2020.08.26 13:25; Turning page is supported! (xbqg [ & xbqg ]) The script edition has a infomation page now. Page-id style is fine-tuned again. Better dividers. Some safety problems are fixed.
  5. 2020.08.26 21:16; When the page-id is illegal, give a warning and exit now. (Regex [0-9]+_[0-9]+/[0-9]+)
  6. 2020.08.27 14:37; Reviewing the current page is supported! (xbqg =) No longer need to turn next and then prev when clearing the screen by accident :)
  7. 2020.08.28 13:52; storage.sh Ohhhhhhhhhhhhh!!!!!!!!!!!
  8. 2020.08.28 15:10; 现在显示 章节名 @ 书名 了!

最后

qwq fk 的 mac 坏了,只能用 Recovery mode,所以洛谷私信联系吧( 能用的 APP 只有 Terminal 和 Safari,被迫学了 bash /fad


EOF

原文
存档评论5 条抓取于