Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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