6

Alternatively, how can you dump the contents of your clipboard to a text file? If at all possible, I'd like this for the actual clipboard, but also the clipboard delegated to highlighted text, and even vim's if you can manage it.

I figure if you can at least echo it, then you should be able to > into a file pretty easily.

Anon
  • 11,863
  • 22
  • 66
  • 122
  • Vim's registers are internal to it, unless you use the `*` or `+` registers, in which case it uses the clipboard(s) – muru Jan 25 '17 at 06:42

1 Answers1

4

Job for xclip:

xclip -o >file.txt
  • -o dumps the current clipboard (precisely selection) content to STDOUT, then you can simply leverage a shell redirection

xclip comes with xclip package, you might need to install it first.

heemayl
  • 90,425
  • 20
  • 200
  • 267
  • two clipboards; that seems to work for highlighted text. Now what about copied text? – Anon Jan 25 '17 at 04:01
  • 1
    @Akiva X11 server has clipboard, which is where copied text goes, and two selections, primary and secondary. `xclip -sel clip -o` releases copied text. Just read tye manual for `xclip` , there's plenty of options – Sergiy Kolodyazhnyy Jan 25 '17 at 04:22