Skip to content

Instantly share code, notes, and snippets.

@Toddses
Created March 16, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Toddses/e1a5e0899f31dd8c882e to your computer and use it in GitHub Desktop.
Save Toddses/e1a5e0899f31dd8c882e to your computer and use it in GitHub Desktop.
Automatically pygmentize more output
# Automatically pygmentize 'more' output
function moar() {
local file=$1;
local ext=${file##*.};
# if it’s a dotfile, treat it as shell script
if [[ $file == .* ]]; then
more $file | pygmentize -l sh;
# if a lexer exists for the file ext, use that
elif pygmentize -L lexers | grep -q "\.${ext}"; then
more $file | pygmentize -l $ext;
# otherwise just let pygmentize figure it out
else
more $file | pygmentize;
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment