Skip to content

Reading from afar

By the end of this chapter you can fetch and read a Markdown document from the web with Glow — and you can state the caveat that comes with fetching anything at all.

A URL is a source

Give Glow an https:// (or http://) address instead of a file path, and it downloads the document and renders it like any other:

$ glow https://raw.githubusercontent.com/charmbracelet/glow/master/README.md

The lab ran exactly that and rendered Glow's own README — 17,289 bytes of plain reading in a pipe — beginning "# Glow / Render markdown on the CLI, with pizzazz!" (transcript glow-lab/transcripts/t06-remote.txt). Nothing is saved to disk; when the command ends, the fetched copy is gone. Read it again, and it is fetched again, possibly changed — these byte counts are a snapshot of one fetch, labelled as such.

The GitHub shorthand

A shorter form fetches a repository's README directly:

$ glow github.com/charmbracelet/glow

The lab compared the two runs byte for byte: identical. The shorthand is not a listing or a summary; it is the README, fetched from the same place. A matching shorthand for GitLab is documented by the project; the lab did not test it and does not present it as run.

Two errors mark the edges:

  • a URL that answers 404 stops the run, exit code 1, with Error: HTTP status 404 and nothing on stdout;
  • a shorthand with no domain — glow charmbracelet/glow — is not understood as a shorthand at all. Glow takes it for a local file path and reports that the file does not exist. The domain is what makes it a fetch.

The network caveat, plainly

Fetching is a network operation, with everything that implies. The document you read is whatever that address serves now, which may differ from what it served yesterday; a rendered README is exactly as trustworthy as the repository it came from, no more. Glow fetches over the same connections any downloader would use, and this guide claims nothing about authentication: a document that needs a login is a document for your browser, not for Glow. Treat the habit as you would any other downloading — fetch from addresses you recognise, and remember the rule from chapter 1 with twice the force: a fetched page is a reading of a document that lives somewhere else, and may have changed since.

Check: pick a project whose README you know, fetch it by raw URL and by shorthand, and diff the two runs — expect silence from diff, and the README on your screen. If you get both, you have this chapter.