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:

  • Moving Beyond Toxic Empathy
  • Genre fiction is more important than literary fiction in our society.
  • Odds and Ends: Optimizing SSHFS, moving files into subdirectories, and getting placeholder images
  • Guns and Holy Week
  • Social Engineering - It can happen to you!
  • 21 Flavors - A Guest 100 Word Story
  • Playing Doctor - A 100 Word Story