Last active
August 29, 2015 14:09
-
-
Save andyfriesen/870e3489c144a5449cbe to your computer and use it in GitHub Desktop.
Use Pygments to colourize code in the clipboard
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/bash | |
set -ex | |
if [ `uname` == 'Linux' ]; then | |
PASTE=xclip\ -o | |
OPEN=xdg-open | |
else | |
# Assume OSX | |
PASTE=pbpaste | |
OPEN=open | |
fi | |
echo "<style>" > colourized.html | |
pygmentize -S colorful -f html -a .highlight >> colourized.html | |
echo "</style>" >> colourized.html | |
echo "<body>" >> colourized.html | |
$PASTE | pygmentize -f html -l $1 >> colourized.html | |
echo "</body>" >> colourized.html | |
$OPEN colourized.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment