Getting a graphic on the clipboard to the disk?

xclip

xclip (man page) is on official repos of major distros (pasteimg it isn't and last update was on 2011).

For me the quickest way is using terminal, going to the desired folder (maybe using autojump) and then just run clipboard2photo, which is an alias I created to the following command:

xclip -selection clipboard -t image/png -o > "$(date +%Y-%m-%d_%T).png"  # Use "Screenshot from $(date "+%Y-%m-%d %H-%M-%S").png" if you like GNOME filename format.

With something on clipboard you can get all possible targets with: xclip -selection clipboard -o -t TARGETS

GNOME Shell shortcuts

On GNOME Shell (Ubuntu 17.10+) we have built in shortcuts to save screenshots directly to ~/Pictures:

screenshot

Hints to remember them:

  • Ctrl → to clipboard (else to ~/Pictures)
  • Alt → Current window
  • Shift → Area/Surface

I usually disable "Print" to avoid generating garbage on ~/Pictures if I miss F12 (which I use a lot with Guake) and accidentally press it.


Tip 1: Put your aliases on ~/Dropbox/.mybashrc (or maybe better .myprofile) and then include this file from .bashrc.

[ -r ~/Dropbox/.mybashrc ] && source ~/Dropbox/.mybashrc

This way you will have them on all your current and future devices. Of course you can also have a ~/.dotfiles with a git repo.

Tip 2: In the same way you can: thisOutputMarkdown | pandoc -s -f markdown -t html | xclip -selection clipboard -t text/html to get formatted HTML to clipboard.
If you have the Markdown text on clipboard replace thisOutputMarkdown with xsel -b.


I just threw together a quick python script that will paste a clipboard image to a file.

It's very basic but it does the job but could be easily extended.

PasteImg


I've been googling for a while and it seems as if there is no clipboard manager yet that supports pasting of an image directly in a folder, even though there is this Nautilus feature request.

So the answer would be paste it in a graphics application (e.g. gimp) and save it.

Tags:

Clipboard