Skip to content

Instantly share code, notes, and snippets.

@dsanson
Created August 25, 2010 20:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dsanson/550174 to your computer and use it in GitHub Desktop.
Save dsanson/550174 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script converts RTF text on the OS X clipboard to HTML.
osascript -e 'the clipboard as «class RTF »' | \
perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \
textutil -format rtf -convert html -stdin -stdout | \
ruby -ne '@found=true if $_ =~ /<body>/; next unless @found; puts $_; exit if $_ =~ /<\/body>/' | \
grep -v "<body>" | \
grep -v "</body>" | \
pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment