Reading books in command line
Non-DRM e-books matters
No sense to debate how important is reading in modern world: learning new skills and life patterns, live news, entertainment, travel and many more. Ernest Hemingway once said: "There is no friend as loyal as a book".
Amazon and many other stores are trying to play with "buy it" vs "rent it"
market relations and allow to download mostly DRM-protected files which can be opened only in a proprietary store, native or web-based. When a store wants to remove some books, they can do it easily by closing access on store website or even removing them from user devices - Amazon did exactly this with Orwell's "1984". So, better buy books without DRM and always prefer "your control" over "vendor control". For classic books, check Project Gutenberg and Standard Ebooks.
e-book titles and content search in command line
If you have plans for California trip next summer and got several travel guides, next move is opening your file manager or EPUB reader and type each location in the search bar. In command line you can do it much more effectively:
$ find ~/books -name "*Sacramento*" -o -name "*Santa Monica*"
Yeah, as you can see, console allows searching several patterns by once, this is a huge step forward vs GUI. In case a searching inside the books, not just their titles, we can use zipgrep
tool:
$ zipgrep "Sacramento" ~/books/One_book.epub
$ for book in ~/books/*epub; do echo $book && zipgrep "Sacramento" "$book"; done
This command will search for all EPUB files in ~/books
.
rga "Sacramento" ~/books/
Another way - use the tool called ripgrep-all, also works with PDF, Office formats and archives like .zip
or .tar.gz
.
Console e-book readers
Epy
The CLI e-book reader, written in Python, licensed under GPLv3; supports EPUB, .mobi and AZW and direct links to Project Gutenberg. Even more, dictionary integration works and can be great for reading books in foreign language. Text-to-speech also supported, requires mimic
or pico2wave
engines. Two-pages mode available for people who like the paper book reading experience.
Probably the easier way to install it - pip3 install epy-reader
, the configuration file located in ~/.config/epy/configuration.json
and supports tuning of hotkeys, dictionary and text-to-speech engine. Starting the reading is also super intuitive: $ epy /path/to/book.epub
.
Main hotkeys:
t
- show book indexn
- jump to next chapterp
- jump to previous chapterb
- add bookmarkB
- list available bookmarks/
- search
Another super useful option is -r
, $ epy -r
will print last used files together with their reading progress and paths, so you can read many books and switch easily in between. $ epy 1
will open first books in reading list.
terminal-book-reader
Simple terminal reader, supports .txt
, HTML and EPUB formats, and licensed under GPLv2. Written in JavaScript; can be installed with npm install terminal-book-reader
. The configuration file located in .config/tbr/tbr.yaml
.
Main hotkeys:
c
- select chapter/
- searchh
- history^D
- next chapter^B
- previous chapter
Converting e-books in command line
Sometimes an e-book reader can't read a format; these devices in general are very limited. Calibre, a Swiss knife application for digital documents can help, and, surprisingly, it also works in command line:
ebook-convert2 book.epub book.mobi
Now the converted e-book is ready for Kindle.
Ecology and Global Warming note
Killing threes for paper in the XXI century is stupid and sad. Use digital books as much as you can and save ecology. Fewer threes mean higher carbon rates in the air, more heat trapping near the Earth's surface and higher temperatures as a result.