Skip to content

Instantly share code, notes, and snippets.

@rock3r
Created September 2, 2020 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rock3r/21af56de107817c6d9e8d1437d6982ae to your computer and use it in GitHub Desktop.
Save rock3r/21af56de107817c6d9e8d1437d6982ae to your computer and use it in GitHub Desktop.
Remove background from RTF text (copied from IntelliJ/Android Studio) via a simple script [macOS only]
#!/bin/sh
# Remove background from RTF text (copied from IntelliJ/Android Studio/...)
# By Sebastiano Poggi, Apache 2.0 license: https://www.apache.org/licenses/LICENSE-2.0
#
# Text is altered in-place in the clipboard. If copying from an IDE, make sure you have the
# "Copy a text fragment" preference set to "Rich text" in the IDE preferences Editor > General.
#
# Also available as a Quick Action to easily install on macOS from here:
# https://www.dropbox.com/s/8qboebourj3jkzo/Copy%20for%20Keynote.workflow.zip?dl=1
osascript -e 'the clipboard as «class RTF »' | \
perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \
perl -pe 's/\\cbpat\d+//' | perl -pe 's/\\cb\d+//' | perl -pe 's/\\box//' | perl -pe 's/\\fs\d+/\\fs96/' | \
pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment