From 3fc1ab9d43541d3d2f2d15a7755334cf1fe35e6b Mon Sep 17 00:00:00 2001 From: Nick Nisi Date: Sun, 13 Jul 2014 12:48:22 -0500 Subject: [PATCH] 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. --- Brewfile | 1 + zsh/functions.zsh | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Brewfile b/Brewfile index eb54e89..5309daa 100644 --- a/Brewfile +++ b/Brewfile @@ -16,6 +16,7 @@ install macvim --override-system-vim install reattach-to-user-namespace install tmux install zsh +install highlight # gitsh tap thoughtbot/formulae diff --git a/zsh/functions.zsh b/zsh/functions.zsh index a6fbc04..7d62a74 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -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 +}