Skip to content
/ reader Public

reader is for your command line what the “readability” view is for modern browsers: A lightweight tool offering better readability of web pages (and EML files!) on the CLI.

License

Notifications You must be signed in to change notification settings

mrusme/reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reader

Static Badge

reader is for your command line what the “readability” view is for modern browsers: A lightweight tool offering better readability of web pages on the CLI.

reader

reader parses a web page (or an EML file) for its actual content and displays it in nicely highlighted text on the command line. In addition, reader renders embedded images from that page as colored block-renders on the terminal as well.

Installation

go install github.com/mrusme/reader@latest

If the above fails, then the following should work:

git clone https://github.com/mrusme/reader.git
cd reader
go install

Usage

reader https://xn--gckvb8fzb.com/superhighway84/

Don't render images:

reader --image-mode none https://xn--gckvb8fzb.com/superhighway84/

Output raw markdown, don't pretty print:

reader -o https://xn--gckvb8fzb.com/superhighway84/

Read from file:

reader ${HOME}/downloads/example.com.html

Read from stdin:

curl -o - https://superhighway84.com | reader -

Render images using the SIXEL graphics encoder:

reader --image-mode sixel https://xn--gckvb8fzb.com/travel-aruba/

sixel

Render EML file:

reader --eml -i none my-email-file.eml

Output EML file raw:

reader --eml --raw my-email-file.eml

Parse an attribute out of a series of *.eml files using pup:

$ /bin/ls -1 ./*@mail.uber.com.eml \
  | while read mail; do reader --raw --eml "$mail" \
    | pup 'td.Uber18_text_p1 span.Uber18_text_p2 text{}'; done
$3.80
$13.72
$17.90
$5.87
$15.90
$24.40
$23.00
$35.00
$27.19
$4.54
$5.07
$8.54
$2.60
$19.81
$25.61
$30.00
€5.90
$4.68
...

So let's say you want a | delimited CSV with all your Uber payments (based on the mails you received from Uber) you could do:

/bin/ls -1 ./*@mail.uber.com.eml \
  | while read mail; do reader --raw --eml "$mail" \
    | pup 'span.Uber18_text_p2, span.Uber18_text_p1 json{}' \
    | jq -r '"| \(.[1].text) | \(.[0].text) |"'; done > ./uber.csv

More options:

reader -h

Examples

Using reader from within w3m

While on a web page in w3m, press ! and enter the following:

reader $W3M_URL

This will open the current url with reader. w3m will wait for you to press any key in order to resume browsing.

If you want to navigate through the page:

reader $W3M_URL | less -R

Using reader from within vim/neovim

Add the following function/mapping to your init.vim:

function s:vertopen_url()
  normal! "uyiW
  let mycommand = "reader " . @u
  execute "vertical terminal " . mycommand
endfunction
noremap <Plug>vertopen_url : call <SID>vertopen_url()<CR>
nmap gx <Plug>vertopen_url

Open a document and place the cursor on a link, then press g followed by x. Vim will open a new terminal and show you the output of reader.

About

reader is for your command line what the “readability” view is for modern browsers: A lightweight tool offering better readability of web pages (and EML files!) on the CLI.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Contributors 5

Languages