Created
March 16, 2015 14:18
-
-
Save Toddses/e1a5e0899f31dd8c882e to your computer and use it in GitHub Desktop.
Automatically pygmentize more output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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