Skip to content

Instantly share code, notes, and snippets.

@combusean
Last active October 10, 2015 13:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save combusean/3695143 to your computer and use it in GitHub Desktop.
Save combusean/3695143 to your computer and use it in GitHub Desktop.
Color less instructions on OS X
1) Run
brew install source-highlight
Presuming you are using brew, of course.
2) Create the file /usr/local/share/source-highlight/src-hilite-lesspipe.sh
with the following as its contents
#!/bin/bash
for source in "$@"; do
case $source in
*ChangeLog|*changelog)
source-highlight --failsafe -f esc --lang-def=changelog.lang --style-file=esc.style -i "$source" ;;
*Makefile|*makefile)
source-highlight --failsafe -f esc --lang-def=makefile.lang --style-file=esc.style -i "$source" ;;
*) source-highlight --failsafe --infer-lang -f esc --style-file=esc.style -i "$source" ;;
esac
done
For some dumb reason, the above bash script doesn't get installed with source-highlight,
so I had to extract the above from the tarball's installation files.
3) chmod a+rx the above file.
4) Add the following lines to your ~/.profile (or equivalent)
export LESSOPEN="| /usr/local/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=' -R '
I think this is it.
--sean
@jhsu
Copy link

jhsu commented Sep 13, 2012

awesome, thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment