Skip to content

Instantly share code, notes, and snippets.

@jorgerance
Created March 5, 2020 22:57
Show Gist options
  • Save jorgerance/a00a8aecd144dfaf1a982e7ec3012bc8 to your computer and use it in GitHub Desktop.
Save jorgerance/a00a8aecd144dfaf1a982e7ec3012bc8 to your computer and use it in GitHub Desktop.
[cat with code highlighting]
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