Get Homebrew installed on your mac if you don't already have it.
brew install highlight
This will highlight the source code in RTF format and copy the result of that operation to your Mac's clipboard.
highlight -O rtf source_file.rb | pbcopy
Parameters examples
highlight -O rtf source_file.rb --line-numbers --font-size 24 --font Inconsolata --style solarized-dark -W -J 50 -j 3 --src-lang ruby | pbcopy
My frequent used config
highlight -O rtf source_file.rb --font-size 24 --font "Source Code Pro" --style moria --src-lang ruby | pbcopy
- forked from https://gist.github.com/jimbojsb/1630790
- highlight document http://www.andre-simon.de/doku/highlight/en/highlight.html