termshot

homeportMIT活跃维护

把终端命令输出直接渲染成带 ANSI 配色的截图,省去手动截屏和排版,适合写文档或发 issue 时贴命令行结果。

Creates screenshots based on terminal command output

v0.6.1发布于 2026-02-09 11:49 UTC982star39fork同步于 2026-11-07 07:33 UTC

怎么上手

由 README 提炼,执行前请确认
brew install homeport/tap/termshot
termshot ls -a
硬件要求按 README 说明

README 未说明,仅提供 macOS/Linux 的 Homebrew 安装与 Darwin、Linux 预编译二进制

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把终端命令输出连同 ANSI 颜色渲染成窗口样式截图的命令行工具

把终端命令输出直接渲染成带 ANSI 配色的截图,省去手动截屏和排版,适合写文档或发 issue 时贴命令行结果。

核心能力

  • 解析命令输出的 ANSI 转义码,保留真实配色
  • 像 time 一样前缀调用,自动生成 out.png
  • 支持 --show-cmd 在图中显示所执行的命令
  • 可调列宽、边距、内边距、阴影与窗口装饰
  • 支持 --edit 先编辑输出再截图,便于去掉敏感内容

容易踩的坑

默认在当前目录生成 out.png,需用 --filename 指定其他路径;含管道的命令要整体用双引号包裹,否则解析有歧义;部分 ANSI 序列(如重置光标位置)尚不能正确解析,截图可能失真

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.6.1
  1. v0.6.1termshot release v0.6.1最新正式版2026-02-09 · 2026-02-09 11:49 UTC

    What's Changed

  2. v0.6.0termshot release v0.6.02025-06-28 · 2025-06-28 16:57 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/homeport/termshot/compare/v0.5.0...v0.6.0

  3. v0.5.0termshot release v0.5.02025-04-08 · 2025-04-08 21:18 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/homeport/termshot/compare/v0.4.1...v0.5.0

  4. v0.4.1termshot release v0.4.12025-01-05 · 2025-01-05 12:39 UTC
    查看更新说明

    Fixes

    • #220
    • #102

    What's Changed

    Full Changelog: https://github.com/homeport/termshot/compare/v0.4.0...v0.4.1

  5. v0.4.0termshot release v0.4.02025-01-02 · 2025-01-02 21:32 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/homeport/termshot/compare/v0.3.0...v0.4.0

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    termshot

    License Go Report Card Tests Codecov Go Reference Release

    Generate beautiful screenshots of your terminal, from your terminal.

    termshot lolcat -f <(figlet -f big termshot)
    

    This command generates this screenshot:

    example

    Installation

    To install with Homebrew on macOS or Linux:

    brew install homeport/tap/termshot
    

    See Releases for pre-compiled binaries for Darwin and Linux.

    Usage

    This tool reads the console output and renders an output image that resembles a user interface window. It's inspired by some other web-based tools like carbon.now.sh, and codekeep.io/screenshot. Unlike those tools, termshot does not blindly apply syntax highlighting to some provided text; instead it reads the ANSI escape codes ("rich text") logged by most command-line tools and uses it to generate a high-fidelity "screenshot" of your terminal output.

    Like time, watch, or perf, just prefix the command you want to screenshot with termshot.

    termshot ls -a
    

    This will generate an image file called out.png in the current directory.

    basic termshot

    In some cases, if your target command contains pipes—there may still be ambiguity, even with --. In these cases, wrap your command in double quotes.

    termshot -- "ls -1 | grep go"
    

    termshot with pipes

    Flags to control the look

    --show-cmd/-c

    Include the target command in the screenshot.

    termshot --show-cmd -- "ls -a"
    

    termshot that shows command

    --columns/-C

    Enforce that screenshot is wrapped after the provided number of columns. Use this flag to make sure that the screenshot does not exceed a certain horizontal length.

    --no-decoration

    Do not draw window decorations (minimize, maximize, and close button).

    --no-shadow

    Do not draw window shadow.

    --margin/-m

    Add extra space (margin) around the window.

    --padding/-p

    Add extra space (padding) around the content inside the window.

    Flags for output related settings

    --clipboard/-b (only on selected platforms)

    Do not create an output file with the screenshot, but save the screenshot image into the operating system clipboard.

    Note: Only available on some platforms. Check termshot help to see if flag is available.

    --filename/-f

    Specify a path where the screenshot should be generated. This can be an absolute path or a relative path; relative paths will be resolved relative to the current working directory. Defaults to out.png.

    termshot -- "ls -a" # defaults to <cwd>/out.png
    termshot --filename my-image.png -- "ls -a"
    termshot --filename screenshots/my-image.png -- "ls -a"
    termshot --filename /Desktop/my-image.png -- "ls -a"
    

    Flags to control content

    --edit/-e

    Edit the output before generating the screenshot. This will open the rich text output in the editor configured in $EDITOR, using vi as a fallback. Use this flag to remove unwanted or sensitive output.

    termshot --edit -- "ls -a"
    

    Miscellaneous flags

    --raw-write <file>

    Write command output as-is into the file that is specified as the flag argument. No screenshot is being created. The command-line flag --filename has no effect, when --raw-write is used.

    --raw-read <file>

    Read input from provided file instead of running a command. If this flag is being used, no pseudo terminal is being created to execute a command. The command-line flags --show-cmd, and --edit have no effect, when --raw-read is used.

    --version/-v

    Print the version of termshot installed.

    $ termshot --version
    termshot version 0.2.5
    

    Multiple commands

    In order to work, termshot uses a pseudo terminal for the command to be executed. For advanced use cases, you can invoke a fully interactive shell, run several commands, and capture the entire output. The screenshot will be created once you terminate the shell.

    termshot /bin/zsh
    

    Please note: This project is work in progress. Although a lot of the ANSI sequences can be parsed, there are definitely commands in existence that create output that cannot be parsed correctly, yet. Also, commands that reset the cursor position are known to create issues.