home / skills / terrylica / cc-skills / terminal-print

This skill prints iTerm2 terminal output to a network printer by generating PDFs and enabling easy sharing of session logs.

npx playbooks add skill terrylica/cc-skills --skill terminal-print

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
3.6 KB
---
name: terminal-print
description: Print iTerm2 terminal output to network printer. TRIGGERS - print terminal, terminal PDF, print session output.
---

# Terminal Print

Print terminal output from iTerm2 to your HP network printer with a single command.

## When to Use This Skill

Use this skill when:

- Printing terminal output to a network printer
- Creating PDF copies of command-line session output
- Archiving terminal logs in print-friendly format
- Sharing terminal output in meetings or documentation

## Quick Start

1. **Copy** terminal output in iTerm2 (Cmd+C)
2. **Invoke** this skill
3. **Review** PDF preview, press Enter to print

## How It Works

```
Clipboard → Strip ANSI → Markdown code block → pandoc/xelatex → PDF → Preview → Print
```

- **ANSI codes stripped**: Colors and escape sequences removed for clean B&W output
- **Monospace font**: DejaVu Sans Mono for proper character alignment
- **Landscape orientation**: Fits ~120 characters per line
- **US Letter paper**: Auto-detected from printer settings

## Execution

```bash
/usr/bin/env bash << 'PRINT_EOF'
SKILL_DIR="${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/marketplaces/cc-skills/plugins/doc-tools}/skills/terminal-print"
bash "$SKILL_DIR/assets/print-terminal.sh"
PRINT_EOF
```

## Options

Run with arguments by modifying the execution block:

```bash
/usr/bin/env bash << 'PRINT_EOF'
SKILL_DIR="${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/marketplaces/cc-skills/plugins/doc-tools}/skills/terminal-print"
bash "$SKILL_DIR/assets/print-terminal.sh" --no-preview
PRINT_EOF
```

| Flag           | Description                              |
| -------------- | ---------------------------------------- |
| `--file FILE`  | Read from file instead of clipboard      |
| `--no-preview` | Skip PDF preview, print directly         |
| `--no-print`   | Generate PDF only, don't send to printer |
| `-h, --help`   | Show help message                        |

## Examples

### Print from clipboard (default)

```bash
# Copy terminal output in iTerm2, then:
/usr/bin/env bash << 'EOF'
bash "${CLAUDE_PLUGIN_ROOT}/skills/terminal-print/assets/print-terminal.sh"
EOF
```

### Print from file

```bash
/usr/bin/env bash << 'EOF'
bash "${CLAUDE_PLUGIN_ROOT}/skills/terminal-print/assets/print-terminal.sh" --file ~/session.log
EOF
```

### Generate PDF only (no print)

```bash
/usr/bin/env bash << 'EOF'
bash "${CLAUDE_PLUGIN_ROOT}/skills/terminal-print/assets/print-terminal.sh" --no-print
EOF
```

## Prerequisites

All dependencies are already available on macOS with MacTeX:

| Tool      | Purpose          | Status            |
| --------- | ---------------- | ----------------- |
| `pandoc`  | Markdown to PDF  | Required          |
| `xelatex` | PDF engine       | Required (MacTeX) |
| `pbpaste` | Clipboard access | Built-in          |
| `lpr`     | CUPS printing    | Built-in          |

## Output

- **PDF location**: `/tmp/terminal-output-YYYYMMDD_HHMMSS.pdf`
- **Markdown source**: `/tmp/terminal-YYYYMMDD_HHMMSS.md`
- **Cleanup**: macOS automatically cleans `/tmp` periodically

## Troubleshooting

### "No text in clipboard"

Copy terminal output first using Cmd+C in iTerm2.

### "Missing pandoc" or "Missing xelatex"

Install MacTeX: `brew install --cask mactex`

### Printer not found

Check printer status: `lpstat -p -d`

The default printer is `HP_LaserJet_Pro_MFP_3101_3108`. Edit the script to change.

## Related Skills

- [pandoc-pdf-generation](../pandoc-pdf-generation/SKILL.md) - General Markdown to PDF conversion
- [asciinema-converter](../../../asciinema-tools/skills/asciinema-converter/SKILL.md) - Convert terminal recordings

Overview

This skill prints iTerm2 terminal output to an HP network printer or generates a PDF with a single command. It converts clipboard or file terminal content into a clean, monospace PDF (ANSI codes removed) and can preview before sending to the printer. The tool is built for macOS environments with pandoc and XeLaTeX available.

How this skill works

The script reads text from the clipboard or a file, strips ANSI escape sequences, wraps the content in a Markdown code block, and converts that Markdown to PDF using pandoc and xelatex. It produces a landscape, monospace PDF optimized for wide terminal lines, previews the PDF by default, and sends it to CUPS with lpr if printing is requested.

When to use it

  • Print recent terminal sessions or command output for meetings or documentation
  • Create a PDF archival copy of a debugging session or log dump
  • Share readable, print-friendly terminal output with non-technical stakeholders
  • Produce a monochrome, fixed-width print of command-line output for records
  • Quickly convert large terminal lines (≈120 chars) into a readable, landscape PDF

Best practices

  • Copy output from iTerm2 (Cmd+C) before invoking the script when using clipboard mode
  • Use --file to print large logs without relying on the clipboard
  • Install MacTeX/pandoc if errors mention missing pandoc or xelatex
  • Preview the PDF first; use --no-preview only when you trust the output
  • Adjust the default printer or paper settings in the script if your environment differs

Example use cases

  • Print a captured build log to hand out at a post-mortem meeting
  • Generate a PDF of a troubleshooting session for ticket attachments
  • Archive a long-running CLI job output as a dated PDF in /tmp
  • Produce printouts of SQL query output or server diagnostics for onboarding

FAQ

What input sources does the skill accept?

It reads text from the macOS clipboard by default or from a file when you pass --file FILE.

What dependencies are required?

pandoc and xelatex (MacTeX) are required. pbpaste and lpr are built into macOS.