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.

Popular posts:

  • HOWTO Make Your Hamburger Helper Better
  • The Songs That Chronicle Our Lives
  • Word Porn Quotes
  • I am not a number; I am a free man, OR, why you should never rely on social media
  • It's not being "Awkward", and the difference between Excuses and Explanations
  • If there's one Nazi (or a racist) at the table...
  • I really like you, but I have to break up with you before I don't.