Skip to content

mechatour/cliphist

 
 

Repository files navigation

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, block mode
  • no concept of a picker, only pipes

requires: go, wl-clipboard, xdg-utils (for image mime inferance)


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 keyboard and write it to the history.
call it once per session - for example in your sway config

select old item

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

delete old item

$ cliphist list | dmenu | cliphist delete
or else query manually
$ cliphist delete-query "secret item"

clear database

$ cliphist wipe


picker examples

dmenu

cliphist list | dmenu | cliphist decode | wl-copy

fzf

cliphist list | fzf | cliphist decode | wl-copy

rofi (dmenu mode)

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

rofi (custom mode)

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

(requires contrib/cliphist-rofi)

rofi (custom mode with images)

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

(requires contrib/cliphist-rofi-img)

wofi

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

why do i have numbers in my picker? can i get rid of them?

it's important that a line prefixed with a number is piped into cliphist decode. this number is used to lookup in the database the exact original selection that you made, with all leading, trailing, non printable etc whitespace presevered. none of that will not 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 column seperator, 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
# 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
how do i narrow down the items that are copied to cliphist, or always copy images from my browser?

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


video

bone.mp4

About

wayland clipboard manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 80.8%
  • Shell 19.2%