terminal-print

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Terminal Print

终端打印

Print terminal output from iTerm2 to your HP network printer with a single command.
只需一条命令,即可将iTerm2中的终端输出打印到你的HP网络打印机。

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
在以下场景使用本技能:
  • 将终端输出打印到网络打印机
  • 生成命令行会话输出的PDF副本
  • 以适合打印的格式归档终端日志
  • 在会议或文档中分享终端输出

Quick Start

快速开始

  1. Copy terminal output in iTerm2 (Cmd+C)
  2. Invoke this skill
  3. Review PDF preview, press Enter to print
  1. 复制 iTerm2中的终端输出(Cmd+C)
  2. 调用 本技能
  3. 预览 PDF,按回车键打印

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
剪贴板 → 移除ANSI代码 → Markdown代码块 → pandoc/xelatex → PDF → 预览 → 打印
  • 移除ANSI代码:去除颜色和转义序列,生成清晰的黑白输出
  • 等宽字体:使用DejaVu Sans Mono确保字符对齐正确
  • 横向排版:每行可容纳约120个字符
  • US Letter纸张:根据打印机设置自动检测

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
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
FlagDescription
--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
修改执行代码块以添加参数运行:
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
参数说明
--file FILE
从文件读取内容而非剪贴板
--no-preview
跳过PDF预览,直接打印
--no-print
仅生成PDF,不发送至打印机
-h, --help
显示帮助信息

Examples

示例

Print from clipboard (default)

从剪贴板打印(默认)

bash
undefined
bash
undefined

Copy terminal output in iTerm2, then:

先在iTerm2中复制终端输出,然后执行:

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

Print from file

从文件打印

bash
/usr/bin/env bash << 'EOF'
bash "${CLAUDE_PLUGIN_ROOT}/skills/terminal-print/assets/print-terminal.sh" --file ~/session.log
EOF
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)

仅生成PDF(不打印)

bash
/usr/bin/env bash << 'EOF'
bash "${CLAUDE_PLUGIN_ROOT}/skills/terminal-print/assets/print-terminal.sh" --no-print
EOF
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:
ToolPurposeStatus
pandoc
Markdown to PDFRequired
xelatex
PDF engineRequired (MacTeX)
pbpaste
Clipboard accessBuilt-in
lpr
CUPS printingBuilt-in
在安装了MacTeX的macOS系统中,所有依赖均已可用:
工具用途状态
pandoc
Markdown转PDF必需
xelatex
PDF引擎必需(需安装MacTeX)
pbpaste
访问剪贴板系统内置
lpr
CUPS打印系统内置

Output

输出

  • PDF location:
    /tmp/terminal-output-YYYYMMDD_HHMMSS.pdf
  • Markdown source:
    /tmp/terminal-YYYYMMDD_HHMMSS.md
  • Cleanup: macOS automatically cleans
    /tmp
    periodically
  • PDF位置
    /tmp/terminal-output-YYYYMMDD_HHMMSS.pdf
  • Markdown源文件
    /tmp/terminal-YYYYMMDD_HHMMSS.md
  • 清理:macOS会定期自动清理
    /tmp
    目录

Troubleshooting

故障排除

"No text in clipboard"

"剪贴板中无文本"

Copy terminal output first using Cmd+C in iTerm2.
先在iTerm2中使用Cmd+C复制终端输出。

"Missing pandoc" or "Missing xelatex"

"缺少pandoc"或"缺少xelatex"

Install MacTeX:
brew install --cask mactex
安装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.
检查打印机状态:
lpstat -p -d
默认打印机为
HP_LaserJet_Pro_MFP_3101_3108
。可编辑脚本修改默认打印机。

Related Skills

相关技能

  • pandoc-pdf-generation - General Markdown to PDF conversion
  • asciinema-converter - Convert terminal recordings
  • pandoc-pdf-generation - 通用Markdown转PDF转换
  • asciinema-converter - 转换终端录制内容