peek
1 Screenshots
2 Command Line
2.1 Options
2.2 Color Modes
2.3 Pagers
3 Supported File Types
3.1 CSS
3.2 HTML
3.3 Markdown
3.4 Java  Script And JSX
3.5 WAT
3.6 Racket
3.7 Scribble
4 Library
5 Notes
9.1

peek🔗ℹ

Jens Axel Søgaard <jensaxel@soegaard.net>

 (require (lib "peek/main.rkt")) package: peek-lib

The tool peek is a terminal utility for previewing files in the terminal.

This package is not intended for use by other Racket programs. Installing the package will give you a command line tool peek you can use instead of less in the terminal. The command peek appears in the same folder, the other Racket launchers do.

There is file-type-aware rendering for the supported file types.

The supported file types are:

CSS, HTML, JavaScript, Markdown, Racket, Scribble, and WAT.

The CSS previewer uses lexers/css for lexing and adds terminal-oriented rendering features such as syntax coloring, color swatches, and optional alignment.

The HTML previewer uses lexers/html and reuses the CSS and JavaScript color model for embedded <style> and <script> content.

The JavaScript previewer uses lexers/javascript, and enables JSX-aware classification for .jsx files.

The Markdown previewer uses lexers/markdown and colors Markdown structure plus delegated embedded languages in .md files.

The Racket previewer uses lexers/racket and provides syntax coloring for .rkt and .rktd files.

The Scribble previewer uses lexers/scribble and colors Scribble command syntax plus embedded Racket escapes in .scrbl files.

The WAT previewer uses lexers/wat and provides first-pass syntax coloring for WebAssembly text-format files in .wat.

1 Screenshots🔗ℹ

A few small previews, rendered by peek:

2 Command Line🔗ℹ

After installing the peek package, the launcher is available as peek.

peek path/to/file.css
peek path/to/file.html
peek path/to/file.js
peek path/to/file.md
peek path/to/file.rkt
peek path/to/file.scrbl
peek path/to/file.wat

When reading from standard input, use --–type to select the file type:

cat path/to/file.css | peek --type css
cat path/to/file.html | peek --type html
cat path/to/file.md | peek --type md
cat path/to/file.rkt | peek --type rkt
cat path/to/file.scrbl | peek --type scrbl
cat path/to/file.wat | peek --type wat

To list the currently supported explicit file type names:

peek --list-file-types

Useful CSS examples:

peek -a path/to/file.css
peek --no-swatches path/to/file.css
peek --color never path/to/file.css
peek --color auto path/to/file.css | less -R
peek -p path/to/file.css

HTML, JavaScript, JSX, Markdown, Racket, Scribble, and WAT examples:

peek path/to/file.html
peek path/to/file.js
peek path/to/component.jsx
peek path/to/file.md
peek path/to/file.rkt
peek path/to/file.scrbl
peek path/to/file.wat

2.1 Options🔗ℹ

  • --–type type selects the input type explicitly. This is mainly useful for standard input. Supported values are css, html, js, jsx, md, rkt, scrbl, and wat.

  • --–list-file-types prints the currently supported explicit file type names, one per line, and exits.

  • --a, --–align enables CSS-specific alignment. This may rewrite spacing to improve the readability of declarations and aligned rule groups.

  • --–no-swatches disables CSS color swatches while keeping syntax coloring enabled.

  • --p, --–pager sends preview output through the configured pager. peek uses the PAGER environment variable when it is set, and otherwise falls back to less -R.

  • --–color always|auto|never controls ANSI color output. The default is always.

2.2 Color Modes🔗ℹ

  • always always emits ANSI color and other terminal styling.

  • auto emits color only when the output port is a terminal.

  • never disables color and prints plain text.

2.3 Pagers🔗ℹ

Use --p or --–pager when you want peek to open its output in a pager instead of writing directly to the terminal.

By default, peek uses:

  • the command named by PAGER, if that environment variable is set

  • less -R, otherwise

On Unix-like systems, a common usage is:

peek -p path/to/file.css

or, with an explicit pager selection:

PAGER="less -R" peek -p path/to/file.css

On Windows, pager availability depends on what is installed. One practical approach is to point PAGER at an installed pager explicitly. For example, if less.exe is available from Git for Windows:

$env:PAGER = "C:\Program Files\Git\usr\bin\less.exe -R"
peek -p path\to\file.css

If PAGER is not set and less is not installed, pager mode will fail with an error instead of silently falling back to plain output.

3 Supported File Types🔗ℹ

The current explicit file type names are:

  • css

  • html

  • js

  • jsx

  • md

  • rkt

  • scrbl

  • wat

3.1 CSS🔗ℹ

For CSS, peek supports:

  • syntax coloring

  • color swatches for practical color literals and supported color functions

  • best-effort previewing on malformed input

  • optional alignment for declarations and simple repeated rule shapes

The CSS aligner is intentionally opinionated and terminal-focused. It may:

  • align property columns inside a block

  • align numeric values, including decimal/unit alignment

  • align repeated simple rule groups across sibling rules

  • align repeated function-call argument shapes, such as repeated rgba(...) calls, when that improves scanability

Swatches are part of the rendered output. Alignment is therefore computed from rendered width, not only from source-text width.

Example CSS preview input:

.card {
  color: #2f7ea0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.20);
}

3.2 HTML🔗ℹ

For HTML, peek currently supports:

  • syntax coloring for HTML structure such as tag names, attribute names, attribute values, comments, entities, and doctypes

  • best-effort previewing on malformed input

  • embedded CSS coloring inside <style> elements

  • embedded JavaScript coloring inside <script> elements

The first HTML pass is intentionally color-only. It does not yet add HTML-specific layout transforms, and it does not enable CSS swatches or alignment inside embedded <style> regions.

Example HTML preview input:

<!doctype html>
<main id="app">
  <style>.hero { color: #2f7ea0;  }</style>
  <script>const root = document.querySelector("#app");</script>
  <p>Hello &amp; goodbye.</p>
</main>

3.3 Markdown🔗ℹ

For Markdown, peek currently supports:

  • syntax coloring for GitHub-Flavored Markdown structure in .md files

  • plain rendering for ordinary prose

  • embedded-language coloring for delegated raw HTML and recognized fenced code languages

  • best-effort previewing on malformed input

The first Markdown pass is intentionally color-only. It does not attempt to render Markdown as formatted documentation, and it does not rewrite table or list layout.

Example Markdown preview input:

  # Demo

  

  Text with `code`, a [link](https://example.com), and:

  

  ```rkt

  (define x 1)

  ```

3.4 JavaScript And JSX🔗ℹ

For JavaScript, peek currently supports:

  • syntax coloring for JavaScript files such as .js, .mjs, and .cjs

  • syntax coloring for JSX in .jsx files

  • derived-tag-driven rendering built on lexers/javascript

The first JavaScript pass focuses on syntax coloring only. It does not yet add preview widgets or framework-specific heuristics.

Example JSX preview input:

const view = <Button kind="primary">Hello {name}</Button>;

3.5 WAT🔗ℹ

For WAT, peek currently supports:

  • syntax coloring for WebAssembly text-format files in .wat

  • best-effort previewing on malformed input

  • delegated WAT coloring in fenced Markdown code blocks when lexers/markdown exposes embedded-wat

The first WAT pass is intentionally color-only. It does not add indentation normalization, formatting, or spec-link behavior. Standalone WAT preview is also the first file type to use the streaming render path in peek; other current file types still use the existing buffered preview path.

Example WAT preview input:

  (module

    (func $answer (result i32)

      i32.const 42)

    (export "answer" (func $answer)))

3.6 Racket🔗ℹ

For Racket, peek currently supports:

  • syntax coloring for .rkt files

  • derived-tag-driven rendering built on lexers/racket

  • best-effort previewing in coloring mode

The first Racket pass is intentionally color-only. It does not yet add structure-aware formatting or separate support for nearby file types such as .rktl.

Example Racket preview input:

"#lang racket/base""\n"
"\n"
"; Greeting helper.""\n"
"#;(+ 1 2)""\n"
"(define (greet #:name [name \"you\"])""\n""  "
  "(string-append \"hi \" name))"

3.7 Scribble🔗ℹ

For Scribble, peek currently supports:

  • syntax coloring for .scrbl files

  • derived-tag-driven rendering built on lexers/scribble

  • plain text left unstyled while command syntax is colored

  • Racket-like coloring for tokens inside Scribble Racket escapes

The first Scribble pass is intentionally color-only. It does not try to render Scribble as a document view; it stays a syntax-oriented terminal preview.

Example Scribble preview input:

 
@title{peek Scribble Demo}
 
This is plain text.
 
Inline Racket: @racket[(define x 1)]
 

4 Library🔗ℹ

The command-line tool is backed by a small library in (lib "peek/preview.rkt").

The initial library surface is intentionally small:

  • make-preview-options constructs a preview-options value with optional type, alignment, swatch, and color-mode settings.

  • preview-string previews a source string using the selected options.

  • preview-port previews from an input port to an output port. This is the lower-level entry point used by streaming previewers such as standalone WAT.

  • preview-file reads a file and previews it using the selected options.

The command-line entry point lives in (lib "peek/main.rkt") and is exported as main.

5 Notes🔗ℹ

Unsupported file types currently fall back to plain text.

The current implementation focuses on CSS, HTML, JavaScript, Markdown, Racket, Scribble, WAT, and a small generic preview pipeline. All supported lexers now use the port-oriented streaming path. Future file types may add their own previewers without forcing all file types into the same rendering model.