Geeky things: X-Clipboard synchronization, file/mime types, and commandline uploading

Geeky things I learned recently:

You can send standard output to multiple processes at the same time using tee:

echo “blah” | tee >(xclip -i -s primary) >(xclip -i -s clipboard)

You can find out if a file is binary using the command “file” and a simple grep operation:

binary=$(file -b $1 | grep text)

And you can find out if a file is an image using xdg-mime:

mimetype=$(xdg-mime query filetype $file| grep image)
if [ “$mimetype” = “” ]; then
echo “Not an image, skipping.”
fi

Related: You can upload to pastebins easily using pastebinit, upload images to imgur from bash, and (woo) do screencaps and upload to imgur in one fell swoop.

See?

Mind you, I started doing this about three hours ago. Because this scene from Malcom in the Middle is what any kind of programming is like.