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 Shell
3.4 Rust
3.5 Rhombus
3.6 Markdown
3.7 Java  Script And JSX
3.8 JSON
3.9 Property Lists
3.10 Plist
3.11 Te  X
3.12 La  Te  X
3.13 WAT
3.14 Racket
3.15 Scribble
4 Library
5 Notes
9.2.0.2

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, Bash, C, Objective-C, C++, CSV, HTML, JavaScript, JSON, LaTeX, Makefile, Markdown, Pascal, Plist, PowerShell, Python, Rhombus, Racket, Rust, Scribble, Swift, TeX, TSV, WAT, YAML, and Zsh.

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

The C previewer uses lexers/c and supports .c and .h files as c preview targets.

The Objective-C previewer uses lexers/objc and supports .m files as objc preview targets.

The C++ previewer uses lexers/cpp and supports common C++ source and header extensions such as .cpp, .cc, .cxx, .cp, .c++, .cppm, .ixx, .hpp, .hh, .hxx, .h++, .ipp, and .tpp files as cpp preview targets.

The Makefile previewer uses lexers/makefile and supports ordinary Makefile, GNUmakefile, and .mk inputs as makefile preview targets. Recipe bodies now preserve Makefile-specific expansions such as $(CC) while using shell-aware roles for the command text itself.

The CSV previewer uses lexers/csv and supports .csv files as csv preview targets.

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 JSON previewer uses lexers/json and supports .json and .webmanifest files as json preview targets.

The Plist previewer uses lexers/plist and supports XML property-list files such as .plist inputs as plist preview targets.

The Python previewer uses lexers/python and supports .py, .pyi, and .pyw files as python preview targets.

The Swift previewer uses lexers/swift and supports .swift files as swift preview targets.

The Rust previewer uses lexers/rust and supports .rs files as rust preview targets.

The Pascal previewer uses lexers/pascal and supports common Pascal source files such as .pas, .pp, .dpr, .lpr, and .inc files as pascal preview targets.

The shell previewers use lexers/shell and support .sh, .bash, .zsh, and .ps1 files as bash, zsh, and powershell preview targets.

The Rhombus previewer uses lexers/rhombus and supports .rhm files as rhombus preview targets.

The YAML previewer uses lexers/yaml and supports .yaml and .yml files as yaml preview targets.

The TSV previewer uses lexers/tsv and supports .tsv files as tsv preview targets.

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, .ss, .scm, 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.c
peek path/to/file.cpp
peek path/to/file.m
peek Makefile
peek GNUmakefile
peek path/to/file.mk
peek path/to/file.csv
peek path/to/file.html
peek path/to/file.js
peek path/to/file.json
peek path/to/file.tex
peek path/to/file.cls
peek path/to/file.sty
peek path/to/file.plist
peek path/to/file.yaml
peek path/to/file.py
peek path/to/file.pas
peek path/to/file.rs
peek path/to/file.swift
peek path/to/file.md
peek path/to/file.rhm
peek path/to/file.rkt
peek path/to/file.ss
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.c | peek --type c
cat path/to/file.cpp | peek --type cpp
cat path/to/file.m | peek --type objc
cat path/to/file.mk | peek --type makefile
cat path/to/file.csv | peek --type csv
cat path/to/file.html | peek --type html
cat path/to/file.md | peek --type md
cat path/to/file.json | peek --type json
cat path/to/file.tex | peek --type tex
cat path/to/file.cls | peek --type latex
cat path/to/file.sty | peek --type latex
cat path/to/file.plist | peek --type plist
cat path/to/file.yaml | peek --type yaml
cat path/to/file.py | peek --type python
cat path/to/file.pas | peek --type pascal
cat path/to/file.rs | peek --type rust
cat path/to/file.swift | peek --type swift
cat path/to/file.rhm | peek --type rhombus
cat path/to/file.rkt | peek --type rkt
cat path/to/file.ss | 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, JSON, LaTeX, Pascal, Plist, Python, JSX, Markdown, Rhombus, Racket, Rust, Scribble, TeX, TSV, YAML, and WAT examples:

peek path/to/file.html
peek path/to/file.c
peek path/to/file.csv
peek path/to/file.js
peek path/to/file.json
peek path/to/file.tex
peek path/to/file.cls
peek path/to/file.sty
peek path/to/file.plist
peek path/to/file.yaml
peek path/to/file.py
peek path/to/file.pas
peek path/to/file.rs
peek path/to/component.jsx
peek path/to/file.md
peek path/to/file.rhm
peek path/to/file.rkt
peek path/to/file.ss
peek path/to/file.scrbl
peek path/to/file.wat

Rhombus examples:

peek path/to/file.rhm

Shell examples:

peek path/to/script.sh
peek path/to/script.bash
peek path/to/script.zsh
peek path/to/script.ps1

2.1 Options🔗ℹ

  • --–type type selects the input type explicitly. This is mainly useful for standard input. Supported values are bash, c, cpp, css, html, js, json, jsx, latex, md, pascal, plist, powershell, python, rhombus, rkt, rust, scrbl, swift, tex, wat, yaml, and zsh.

  • --–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:

  • bash

  • c

  • cpp

  • css

  • html

  • js

  • json

  • jsx

  • latex

  • md

  • plist

  • powershell

  • python

  • rhombus

  • rkt

  • scrbl

  • swift

  • tex

  • wat

  • zsh

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 Shell🔗ℹ

For Shell, peek currently supports:

  • syntax coloring for Bash, Zsh, and PowerShell source

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The shell previewers are intentionally color-only. They do not add layout rewriting or alignment, and they preserve source text and line breaks after ANSI stripping.

Example shell preview input:

#!/usr/bin/env bash
export PATH
echo "$PATH"

3.4 Rust🔗ℹ

For Rust, peek currently supports:

  • syntax coloring for Rust source in .rs files

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The Rust previewer is intentionally color-only. It does not add layout rewriting or alignment, and it preserves source text and line breaks after ANSI stripping.

Example Rust preview input:

  /// Demo

  fn greet(name: &str) -> String {

      format!("hello, {name}")

  }

3.5 Rhombus🔗ℹ

For Rhombus, peek currently supports:

  • syntax coloring for Rhombus source in .rhm files

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The Rhombus previewer is intentionally color-only. It does not add layout rewriting or alignment, and it preserves source text and line breaks after ANSI stripping.

Example Rhombus preview input:

#lang rhombus
fun greet(name):
  println("hello, $(name)")

3.6 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.7 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.8 JSON🔗ℹ

For JSON, peek currently supports:

  • syntax coloring for ordinary JSON source in .json and .webmanifest files

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The JSON previewer is intentionally color-only. It does not add layout rewriting or alignment, and it preserves source text and line breaks after ANSI stripping.

Example JSON preview input:

  {

    "name": "peek",

    "ok": true,

    "count": 2

  }

3.9 Property Lists🔗ℹ

For property lists, peek currently supports:

  • syntax coloring for XML property-list files in .plist inputs

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The Plist previewer is intentionally color-only. It does not add layout rewriting or alignment, and it preserves source text and line breaks after ANSI stripping.

Example property-list preview input:

  <?xml version="1.0" encoding="UTF-8"?>

  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

  <plist version="1.0">

    <dict>

      <key>Name</key>

      <string>peek</string>

    </dict>

  </plist>

3.10 Plist🔗ℹ

For Plist, peek currently supports:

  • syntax coloring for XML property-list files in .plist inputs

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The Plist previewer is intentionally color-only. It does not add layout rewriting or alignment, and it preserves source text and line breaks after ANSI stripping.

Example Plist preview input:

  <?xml version="1.0" encoding="UTF-8"?>

  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

  <plist version="1.0">

    <dict>

      <key>Name</key>

      <string>peek</string>

    </dict>

  </plist>

3.11 TeX🔗ℹ

For TeX, peek currently supports:

  • syntax coloring for .tex source

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The TeX previewer is intentionally color-only. It does not add layout rewriting or alignment, and it preserves source text and line breaks after ANSI stripping.

Example TeX preview input:

  \section{Demo}

  

  Text with \% and $x+y$.

3.12 LaTeX🔗ℹ

For LaTeX, peek currently supports:

  • syntax coloring for common LaTeX source files such as .cls, .sty, .latex, and .ltx

  • best-effort previewing on malformed input

  • source-preserving, color-only terminal output

The LaTeX previewer is intentionally color-only. It does not add layout rewriting or alignment, and it preserves source text and line breaks after ANSI stripping.

Example LaTeX preview input:

  \NeedsTeXFormat{LaTeX2e}

  \ProvidesClass{demo}

  \LoadClass{article}

3.13 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 one of the streaming render paths in peek; all current file types now use the port-oriented streaming path.

Example WAT preview input:

  (module

    (func $answer (result i32)

      i32.const 42)

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

3.14 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
; Greeting helper.
#;(+ 1 2)
(define (greet #:name [name "you"])
  (string-append "hi " name))

3.15 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, Plist, Racket, Scribble, TeX, LaTeX, WAT, and a small generic preview pipeline. Most supported lexers use the port-oriented streaming path. CSS remains the special buffered renderer because it can add swatches and alignment. Future file types may add their own previewers without forcing all file types into the same rendering model.