Created
June 21, 2015 17:00
-
-
Save chrisdev/b6b2a150a1d51454b9a0 to your computer and use it in GitHub Desktop.
Highlight a given file and copy it as RTF
This file contains hidden or 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/zsh | |
# | |
# Highlight a given file and copy it as RTF. | |
# | |
## Simon Olofsson <[email protected]> | |
# | |
# | |
set -o errexit | |
set -o nounset | |
# 1. Run pygmentize | |
# 2. Set the fontsize to 30 Points (=60 half-points) | |
# 3. Remove all newlines | |
# 4. Remove trailing paragraph, to prevent a line break | |
# 5. Copy the result to the clipboard | |
pygmentize -f rtf -O 'fontface=Monaco,style=tango' $1 | sed 's;\\f0;\\f0\\fs60;g' | tr -d '\n' | sed 's;\\par}$;};' | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment