Skip to content

Instantly share code, notes, and snippets.

@andreasbovens
Last active December 3, 2018 10:59
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreasbovens/5773527 to your computer and use it in GitHub Desktop.
Save andreasbovens/5773527 to your computer and use it in GitHub Desktop.
How to quickly create a "Convert to data URI" context menu option on Mac

Setup

  1. Download https://gist.github.com/jsocol/1089733 and unpack
  2. Rename data-uri.py to data-uri and copy to /usr/local/bin/
  3. Open Terminal, cd /usr/local/bin/ and and then chmod +x data-uri (enter password when prompted)
  4. Open Automator, choose New > Service.
  5. Set up the service as follows:
    Service receives selected files or folders in Finder.app
    which is connected to a Run Shell Script action, with the following settings:
    Shell: /bin/bash
    Pass input: as arguments
  for f 
  do
    /usr/local/bin/data-uri "$f" | pbcopy
  done

And save as convert-to-datauri
See http://grab.by/nuCE for a visual overview.

How to use

Right click on any file and select the convert-to-datauri option in the Services submenu. The data URI is copied to the clipboard and is ready to be pasted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment