cliphist

sentrizGPL-3.0活跃维护

Wayland 下的剪贴板管理器,支持文本和图片等多媒体内容,适合 Sway、Hyprland 等 wl-roots 桌面环境。

Wayland clipboard manager with support for multimedia

v0.7.0发布于 2025-10-11 13:23 UTC1,574star48fork同步于 2026-11-07 07:33 UTC

怎么上手

由 README 提炼,执行前请确认
go install go.senan.xyz/cliphist@latest
wl-paste --watch cliphist store
硬件要求按 README 说明

README 未说明硬件要求;运行在 Wayland 环境,需安装 wl-clipboard 和 xdg-utils。

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

项目说明

由 README 自动翻译提炼

Wayland 剪贴板历史管理器,把文本和图片存进历史文件,再用 dmenu/rofi 等选择器取回

Wayland 下的剪贴板管理器,支持文本和图片等多媒体内容,适合 Sway、Hyprland 等 wl-roots 桌面环境。

核心能力

  • 用 wl-paste --watch 监听剪贴板变化并写入历史文件
  • 支持文本和图片,按字节原样保存空白与换行
  • 只输出管道数据,配合 dmenu、rofi、wofi、fzf 等选择器
  • list 支持 -fields 输出 id、mime、preview 等 TSV 元数据
  • 支持按时间清理旧条目和压缩数据库

容易踩的坑

需要 wl-clipboard 版本包含 PR #297(v2.3.0 之后合并),旧版本无法识别 MIME 类型;图片预览脚本需额外安装 chafa 并依赖支持 sixel 的终端;选择器输出必须带 id 前缀管道给 cliphist decode,否则无法还原原始内容。

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

最近发版

5 个版本v0.7.0
  1. v0.7.0cliphist v0.7.0最新正式版2025-10-11 · 2025-10-11 13:23 UTC

    A small release, mostly featuring the min-store-length option.

    Features

    Bug Fixes

    • error when id not during decode (b35d005), closes #159
    • min-store-length sets max length instead of min (#163) (a94f192)
  2. v0.6.1cliphist v0.6.12024-10-15 · 2024-10-15 23:44 UTC
    查看更新说明

    Bug Fixes

    • case when no XDG_{CACHE,CONFIG}_HOME (b3d4bd4), closes #118
  3. v0.6.0cliphist v0.6.02024-10-15 · 2024-10-15 20:52 UTC
    查看更新说明

    Features

    • add -preview-width option to limit char width of preview (#88) (4714de1)
    • contrib: resize images in wofi script to make them clearly visible (#105) (05d29dc)
    • contrib: use "magick" instead of "convert" (#104) (c164c4c)
    • make db path configurable (flag / env var / config file) (19ef90e), closes #91
    • support configuration via env var or config file (#90) (08ee1fb)

    Bug Fixes

    • correctly truncate utf-8 string (9128c08), closes #82
  4. v0.5.0cliphist v0.5.02024-02-08 · 2024-02-08 21:04 UTC
    查看更新说明

    Features

    • accept multiple input lines for cliphist delete (fbc54c0), closes #63
    • add support for bmp images (3c9a7b8), closes #46
    • add version command (3e91638)
    • allow passing an id directly to decode (a2ead3d)
    • clear last entry if we get clear from CLIPBOARD_STATE (5764b03), closes #58
    • contrib: add rofi script with support for displaying images (#70) (3da9a90)
    • contrib: speed up cliphist-rofi-img script and make compatible with 0.4 (95c1936), closes #71
    • don't store items >5MB (594ca54), closes #68
    • show image size and dimensions in preview (dd3c5f0)
  5. v0.4.0cliphist v0.4.02023-03-08 · 2023-03-08 10:39 UTC
    查看更新说明

    Features

    • add -max-items and -max-dedupe-search command line args (df85b70), closes #35
    • add "wipe" command (c2e08d9)
    • use tab as the id separator (bf792ca)

用户点评

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

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

    README 原文

    未翻译

    cliphist

    Clipboard history “manager” for Wayland

    • Write clipboard changes to a history file.
    • Recall history with dmenu, rofi, wofi (or whatever other picker you like).
    • Both text and images are supported.
    • Clipboard is preserved byte-for-byte.
      • Leading/trailing whitespace, no whitespace, or newlines are preserved.
      • Won’t break fancy editor selections like Vim wordwise, linewise, or block mode.
    • No concept of a picker, only pipes.

    Requires Go, wl-clipboard, and xdg-utils (for MIME inference by wl-copy when no type is supplied).


    Install

    • You could try using your distro's repos if it's available there.
    • Or stick a static binary from the releases page somewhere in your $PATH.
    • Or just install it from source with Go and $ go install go.senan.xyz/cliphist@latest.

    Usage

    Listen for clipboard changes

    $ wl-paste --watch cliphist store
    This will listen for changes on your primary clipboard and write them to the history.
    Call it once per session - for example, in your Sway config.

    store reads CLIPBOARD_TYPE from wl-paste --watch (requires wl-clipboard PR #297, merged after v2.3.0). Older wl-clipboard versions leave MIME types unknown.

    Select an old item

    $ cliphist list | dmenu | cliphist decode | wl-copy
    Bind it to something nice on your keyboard.

    List metadata
    cliphist list -fields id,mime,preview
    cliphist list -fields id,format
    cliphist list -fields id,timestamp
    cliphist list -fields mime 123
    cliphist -db-path /some/db list -fields id,timestamp
    cliphist list -h
    

    list emits TSV without a header, newest first. -fields selects columns in the requested order; the default is id,preview. An optional ID selects one entry. Unknown fields and missing IDs are errors.

    Delete an old item

    $ cliphist list | dmenu | cliphist delete
    Or else query manually: $ cliphist delete-query "secret item".

    Clear database

    $ cliphist wipe.

    Expire old entries

    Run this from a timer to delete entries older than 30 days:

    cliphist wipe -older-than 720h
    

    The duration is a Go duration, so days must be given in hours. Entries stored before cliphist tracked timestamps count as older than any cutoff.

    Compact database

    $ cliphist compact.


    Picker examples

    cliphist list | dmenu | cliphist decode | wl-copy

    cliphist list | fzf --no-sort | cliphist decode | wl-copy

    ./cliphist-fzf-sixel

    Requires contrib/cliphist-fzf-sixel, chafa, and a sixel-capable terminal. Uses MIME metadata for image previews and restoration.

    cliphist list | rofi -dmenu | cliphist decode | wl-copy

    cliphist list | fuzzel --dmenu | cliphist decode | wl-copy

    ./cliphist-fuzzel-img

    (Requires contrib/cliphist-fuzzel-img)

    cmenu runs the script itself, so instead of a pipe you give it a script that prints the list, and gets the selected line back. See menu-clipboard for an example.

    rofi -modi clipboard:/path/to/cliphist-rofi -show clipboard

    (Requires contrib/cliphist-rofi).

    rofi -modi clipboard:/path/to/cliphist-rofi-img -show clipboard -show-icons

    (Requires contrib/cliphist-rofi-img).

    cliphist list | wofi -S dmenu | cliphist decode | wl-copy

    Example config for Sway:

    exec wl-paste --watch cliphist store
    bindsym Mod1+p exec cliphist list | wofi -S dmenu | cliphist decode | wl-copy
    

    FAQ

    It's important that a line prefixed with a number is piped into cliphist decode. This number is used to look up in the database the exact original selection that you made, with all leading, trailing, non-printable, etc. whitespace preserved. None of that will be shown in the preview output of cliphist list.

    Since the format of cliphist list is "<id>\t<100 char preview>", and most pickers consider "\t" to be a column separator, you can try to just select column number 2.

    # fzf
    cliphist list | fzf -d $'\t' --with-nth 2 | cliphist decode | wl-copy
    
    # rofi
    cliphist list | rofi -dmenu -display-columns 2 | cliphist decode | wl-copy
    
    # fuzzel
    cliphist list | fuzzel --dmenu --with-nth 2 | cliphist decode | wl-copy
    
    # wofi
    # It kind of works but breaks with quotes in the original selection. I recommend not trying to hide the column with wofi.
    cliphist list | wofi --dmenu --pre-display-cmd "echo '%s' | cut -f 2" | cliphist decode | wl-copy
    

    It's also possible to run wl-paste --watch several times for multiple MIME types.

    For example, in your window manager's startup, you could run:

    wl-paste --type text --watch cliphist store
    wl-paste --type image --watch cliphist store
    

    Now you should have text and raw image data available in your history. Make sure you have xdg-utils installed too.


    Packaging


    Demo

    https://user-images.githubusercontent.com/6832539/230513908-b841fffe-d7d5-46c2-b29f-28b3e91daa74.mp4


    Configuration

    cliphist can be optionally configured to extend the default functionality. Global options can be provided with a CLI argument, environment variable, or config file key. Global CLI flags go before the command. The command-local list -fields flag is CLI-only; environment variables and config keys cannot change the output fields.

    For example, the option max-items, can be set via the CLI as -max-items 100, as an environment variable CLIPHIST_MAX_ITEMS=100, or in the config file as max-items 100.

    If you choose to use the config file, the default location is $XDG_CONFIG_HOME/cliphist/config. The format is a text file with one option per line, where each line is <key> <value>. For example:

    # example cliphist config
    max-items 1000
    max-dedupe-search 200
    

    The list of available options is:

    CLI argumentEnvironment variableConfig file keyDescription
    -max-dedupe-searchCLIPHIST_MAX_DEDUPE_SEARCHmax-dedupe-search(Optional) maximum number of last items to look through when finding duplicates (default 100)
    -max-itemsCLIPHIST_MAX_ITEMSmax-items(Optional) maximum number of items to store (default 750)
    -max-store-sizeCLIPHIST_MAX_STORE_SIZEmax-store-size(Optional) maximum size of clipboard item to store, e.g. 5MB, 10MiB, 1GB (default 5MB)
    -min-store-lengthCLIPHIST_MIN_STORE_LENGTHmin-store-length(Optional) minimum number of characters to store
    -preview-widthCLIPHIST_PREVIEW_WIDTHpreview-width(Optional) maximum number of characters to preview (default 100)
    -db-pathCLIPHIST_DB_PATHdb-path(Optional) path to db (default $XDG_CACHE_HOME/cliphist/db)
    -config-pathCLIPHIST_CONFIG_PATH(Optional) path to config (default $XDG_CONFIG_HOME/cliphist/config)