Created
February 16, 2014 19:00
-
-
Save avdi/9038972 to your computer and use it in GitHub Desktop.
Get syntax highlighted source code for pasting into e.g. Google Docs on Linux
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
# You will need the pygments and xclip packages | |
# This example highlights some Bash source code | |
# '-O noclasses=true' tells pygments to embed colors inline in the source | |
# the '-t text/html' option tells xclip what "target" to specify for the selection | |
pygmentize -l bash -f html -O noclasses=true mysource.sh | xclip -selection clipboard -t text/html |
FWIW this is what it looks like on OSX. Note, my version highlights whatever is on the clipboard. So running:
clipsyn bash
Would take whatever is on the clipboard, syntax highlight it as a bash script and then copy it back to the clipboard.
function clipsyn {
local syntax_type="$1"
pbpaste | pygmentize -l $syntax_type -f rtf | pbcopy -Prefer rtf
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @avdi, I think it would be helpful if you mention about encoding option.
For example:
pygmentize -l java -f html -O noclasses=true,encoding=utf-8 Main.java | pbcopy