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.

Revisions

  1. jorgerance created this gist Mar 5, 2020.
    18 changes: 18 additions & 0 deletions cat.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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
    }