Skip to content

The file browser

By the end of this chapter you know what happens when Glow is given no document at all, what the built-in pager shows, and which files the browser can and cannot see.

No argument: the document list

On a terminal, with nothing piped in, this —

glow

— opens a full-screen list of the Markdown documents around you. The lab opened it in a folder of nine specimens; the final screen, reconstructed afterwards with a terminal emulator (the method is described below), read:

    Glow

   7 documents

 │ kitchen-sink.md
 │ 13 minutes ago

   long-paragraph.md
   23 minutes ago

   newlines.md
   16 minutes ago
   …

   / find • r refresh • e edit • q quit • ? more

(transcript glow-lab/transcripts/t08-tui.txt). Each entry shows its name and how long ago it changed, and the list runs alphabetically; the footer lists the keys — / to find, r to refresh, e to edit the selected document in your editor, q to quit, ? for more. (The relative ages are the lab clock's; yours will say your files' real ages.)

How the lab can quote a screen at all: an interactive program leaves nothing behind, so the lab drove Glow under a pretend terminal — a program that plays the terminal's part, answers Glow's questions, sends keystrokes on a schedule, and records every byte. The recording was then played through a terminal emulator library to rebuild the final screen (glow-lab/answer-terminal.py, glow-lab/final-screen.py). The screens quoted in this chapter are that reconstruction, not photographs.

What the browser can see

The list shows only files with Markdown extensions — the lab's folder also held a file with no extension and a .txt file; neither appeared, even though chapter 2 showed the extensionless file renders fine when named directly. The browser is pickier than the reader.

Inside a git repository, the search covers the whole tree, not just the folder you stand in. The lab opened Glow in the checkout of a sister guide and was offered 18 documents — every .md at its root plus one in a subfolder. In a large repository, expect a crowd.

Two switches widen the net:

  • glow <directory> opens the browser in that directory instead.
  • -a (the configuration file's all: setting) adds hidden files: the lab's two-file test folder showed "1 document" without it and "2 documents" with it, the hidden .hidden.md listed first.

The built-in pager

ENTER opens the selected document in Glow's own pager — the same pager -t file.md opens directly:

|    Kitchen Sink
|
|   A paragraph with struck-through words and a bare address,
|   https://example.org/plain, and an Esc key in inline HTML.
|   …
|  Glow  kitchen-sink.md                                  100%  ? Help

A header reads Glow and the file's name; the footer shows how far through the document you are and offers ? for help. ESC returns to the list; q quits. Two differences from the printed page are worth knowing: the pager renders at your window's width — in the lab, lines ran to about 97 characters on a 100-column window, where the printed page would have stopped at 78 — and with -l, it can number the lines:

   2   Packing List
   4  A short list for a weekend away.
   6  • Waterproof jacket

Those numbers count rendered lines, blank ones included — the packing list's twelve numbered lines are its page, not its ten-line source (chapter 9 warned of this).

One flag belongs here by rights: -m (mouse support) exists in Glow's man page, though not in its --help. The lab confirmed the flag is accepted; as a TUI-only setting it changes nothing about a printed rendering, and driving a mouse through the pretend terminal is beyond what the lab attempted — clicking and wheel scrolling in the browser are documented behaviour, not lab-run.

Check: stand in a folder with a few Markdown files and run glow bare. Count the documents, open one with ENTER, come back with ESC, quit with q. Then run it where an extensionless note lives and confirm the note is not offered — although glow <that-note> reads it happily. If all four match, you have this chapter.