Created
September 2, 2020 16:03
-
-
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]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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