Print iTerm2 terminal output to network printer. TRIGGERS - print terminal, terminal PDF, print session output.
Print terminal output from iTerm2 to your HP network printer with a single command.
Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed โ fix this file immediately, don't defer. Only update for real, reproducible issues.
Use this skill when:
Clipboard โ Strip ANSI โ Markdown code block โ pandoc/xelatex โ PDF โ Preview โ Print
/usr/bin/env bash << 'PRINT_EOF'
SKILL_DIR="$(cc-plugin-root doc-tools)/skills/terminal-print"
bash "$SKILL_DIR/assets/print-terminal.sh"
PRINT_EOF
Run with arguments by modifying the execution block:
/usr/bin/env bash << 'PRINT_EOF'
SKILL_DIR="$(cc-plugin-root 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 |
--printer NAME |
Override target printer queue (default: system default) |
--bypass-airprint |
Use socket-9100 + PostScript queue. Workaround for HP LaserJet Pro MFP 3101/3108/3201/3208/3301/3308 AirPrint blank pages. |
-h, --help |
Show help message |
# Copy terminal output in iTerm2, then:
/usr/bin/env bash << 'EOF'
bash "$(cc-plugin-root doc-tools)/skills/terminal-print/assets/print-terminal.sh"
EOF
/usr/bin/env bash << 'EOF'
bash "$(cc-plugin-root doc-tools)/skills/terminal-print/assets/print-terminal.sh" --file ~/session.log
EOF
/usr/bin/env bash << 'EOF'
bash "$(cc-plugin-root doc-tools)/skills/terminal-print/assets/print-terminal.sh" --no-print
EOF
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 |
/tmp/terminal-output-YYYYMMDD_HHMMSS.pdf/tmp/terminal-YYYYMMDD_HHMMSS.md/tmp periodicallyCopy terminal output first using Cmd+C in iTerm2.
Install MacTeX: brew install --cask mactex
Check printer status: lpstat -p -d
The script auto-detects the system default printer. Override with --printer NAME or set TERMINAL_PRINT_PRINTER in the environment.
lpr reported success but nothing printed)Strong fingerprint of the HP LaserJet Pro MFP 3101/3108/3201/3208/3301/3308 AirPrint blank-page bug โ the printer's IPP-Everywhere PDF interpreter silently drops jobs while CUPS reports completed. Confirmed with this exact symptom on 2026-05-09.
Quick fix:
# 1. One-time setup of bypass queue (socket-9100 + Generic PostScript PPD)
"$(cc-plugin-root doc-tools)/skills/terminal-print/assets/setup-socket-9100-queue.sh"
# 2. Reprint with --bypass-airprint
bash "$(cc-plugin-root doc-tools)/skills/terminal-print/assets/print-terminal.sh" --bypass-airprint
Full diagnostic playbook with command sequences and decision tree: see airprint-blank-page-troubleshooting.md.
Key takeaway: do not trust lpstat -o or job-state=completed โ query the printer's own job ledger via ipptool -tv ipp://<printer>.local.:631/ipp/print for job-impressions-completed and job-media-sheets-completed. CUPS lies; the printer (mostly) tells the truth.
After this skill completes, check before closing:
Only update if the issue is real and reproducible โ not speculative.
