Last active
December 18, 2015 19:29
-
-
Save zachallaun/5833659 to your computer and use it in GitHub Desktop.
Zsh function to copy pygmentized code as RTF to clipboard. Can be pasted directly into applications like Keynote. Based on https://gist.github.com/cormacrelf/2282280.
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
| # copy pygmentized code to clipboard as rtf | |
| # | |
| # $ copyrtf code.py | |
| # $ copyrtf code.py monokai | |
| # $ copyrtf code.py monokai 24 | |
| copyrtf() { | |
| local STYLE | |
| local FONTSIZE | |
| if [[ -z $2 ]]; then | |
| STYLE="monokai" | |
| else | |
| STYLE=$2 | |
| fi | |
| if [[ -z $3 ]]; then | |
| FONTSIZE=24 | |
| else | |
| FONTSIZE=$3 | |
| fi | |
| pygmentize -f rtf -O "style=$STYLE,fontface=Inconsolata" $1 | | |
| # font size (RTF font sizes are doubled) | |
| sed "s/\\\\f0/\\\\f0\\\\fs$(($FONTSIZE * 2))/g" | | |
| pbcopy | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment