Created
March 5, 2020 22:57
-
-
Save jorgerance/a00a8aecd144dfaf1a982e7ec3012bc8 to your computer and use it in GitHub Desktop.
[cat with code highlighting]
This file contains 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
cat() { | |
arguments="$*" | |
for i in $arguments; do | |
argument=$i | |
file_type=$(mdls "$argument"|grep '^kMDItemContentType '|awk -d'=' '{printf $3}'|tr -d '"') | |
printf "\n\n >>> File type: %s \n\n\n" "$file_type" | |
case "$file_type" in | |
"public.python-script"|"public.shell-script") | |
highlight -O ansi --force "$argument" | |
;; | |
*) | |
cat "$argument" | |
;; | |
esac | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment