add highlight from brew and hl command

hl command accepts syntax type and optionally a filename as arguments.
If a filename is given, it will syntax highlight the file and place the
contents on the clipboard. If no file is given, it will use the contents
of the clipboard.
This commit is contained in:
Nick Nisi
2014-07-13 12:48:22 -05:00
parent 598f9c9a30
commit 3fc1ab9d43
2 changed files with 12 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ install macvim --override-system-vim
install reattach-to-user-namespace
install tmux
install zsh
install highlight
# gitsh
tap thoughtbot/formulae

View File

@@ -118,3 +118,14 @@ function gi() {
function gci() {
npm install --save-dev grunt-contrib-"$@"
}
# syntax highlight the contents of a file or the clipboard and place the result on the clipboard
function hl() {
if [ -z "$2" ]; then
src=$( pbpaste )
else
src=$( cat $2 )
fi
echo $src | highlight -O rtf --syntax $1 --font Inconsoloata --style moria --font-size 24 | pbcopy
}