Skip to main content
Glow can render markdown and pipe the output to a pager for easier navigation of long documents.

Using the —pager Flag

Enable pager mode with the --pager (or -p) flag:
glow README.md --pager
glow document.md -p

Default Pager

By default, Glow uses less -r as the pager:
case pager || cmd.Flags().Changed("pager"):
    pagerCmd := os.Getenv("PAGER")
    if pagerCmd == "" {
        pagerCmd = "less -r"
    }
The -r flag tells less to display ANSI color codes correctly, preserving Glow’s syntax highlighting and styling.

PAGER Environment Variable

Customize the pager by setting the PAGER environment variable:
export PAGER="less -r"
glow README.md --pager

Using Custom Pagers

You can use any pager that accepts input from stdin:
# Use most instead of less
export PAGER="most"
glow README.md -p
# Use bat as a pager with line numbers
export PAGER="bat --paging=always --style=plain"
glow document.md --pager
# Use more (basic pager)
export PAGER="more"
glow README.md -p
Make sure your pager supports ANSI color codes (like less -r) to preserve Glow’s styling.

Pager vs TUI Mode

Glow offers two modes for viewing markdown:

Pager Mode

  • Uses external pager program
  • Simple, familiar navigation
  • Good for single documents
  • Activated with --pager

TUI Mode

  • Built-in interactive interface
  • File browsing capabilities
  • Advanced navigation features
  • Activated with --tui

Mutual Exclusivity

You cannot use both modes simultaneously. Glow will return an error:
if pager && tui {
    return errors.New("cannot use both pager and tui")
}
# This will fail
glow README.md --pager --tui
# Error: cannot use both pager and tui

Pager Implementation

Here’s how Glow executes the pager (main.go:316-329):
case pager || cmd.Flags().Changed("pager"):
    pagerCmd := os.Getenv("PAGER")
    if pagerCmd == "" {
        pagerCmd = "less -r"
    }

    pa := strings.Split(pagerCmd, " ")
    c := exec.Command(pa[0], pa[1:]...)
    c.Stdin = strings.NewReader(out)
    c.Stdout = os.Stdout
    if err := c.Run(); err != nil {
        return fmt.Errorf("unable to run command: %w", err)
    }
  1. Checks the PAGER environment variable
  2. Defaults to less -r if not set
  3. Splits the command into program and arguments
  4. Pipes the rendered markdown to the pager

Configuration File

Set pager as the default viewing mode in your configuration file (~/.config/glow/glow.yml):
pager: true

Examples

# Basic pager usage
glow README.md --pager

# Temporary pager override
PAGER="most" glow document.md -p

# Use less with additional options
export PAGER="less -r -F -X"
glow README.md --pager

Common Pager Options

less options:
  • -r - Display ANSI colors correctly
  • -F - Quit if content fits on one screen
  • -X - Don’t clear screen on exit
  • -S - Disable line wrapping
# Less with quit-if-one-screen and no-clear
export PAGER="less -rFX"
glow README.md -p
If you frequently use pager mode, set it as default in your configuration file rather than using the flag every time.

Build docs developers (and LLMs) love