Yeah. ccze. is awesome! I really wanted to use it across my systems and with all applicable commands like head, tail, cat, etc..
So I wrote a zsh function to check if the command exists and utilize it. This was kind of a pain because of the corner cases (people using pipes or redirection with the command etc..)
Through it all, I created two new commands, catless and tacless. Read some of the comments to find why.

Hopefully this serves as a great resource for anyone who is manipulating an already existent command. Also, this and this can help explain some of what I used/did.

### Here we use log highlighting when catting files..some care has to be taken since we are modifying the cat command.
# The defacto is to use "catless" and the following handles it with or without the command existent so I'll try to get used to that.
# The only problem with this is cases where you do a "cat herpderp | less" which will be considered as not going to the terminal hence because
# we protect against this for redirection, we have to also do it for pipes (e.g. -t 1). Basically, we have no way of detecing if the user
# used a pipe or not. Kind of annoying. However, all other commands should work just like normal.

if hash ccze 2>/dev/null ; then

    function cat {
        if [ -t 1 ]; then
            # We are returning to the terminal, lets color!
            ccze -A < $@ ## I could have just done cat $@ | ccze -A, but this way is more fun:)
        else
            # We are pushing elsewhere, either a pipe or redirection, either way, not going to the terminal.
            command cat $@
        fi
    }
    function tac {
        if [ -t 1 ]; then
            command tac $@ | ccze -A
        else
            command tac $@
        fi
    }
    function catless {
    ## providing "less" (lol, i love less) functionality with coloring...sadly, we can't just detect if someone is piping to less
        command cat $@ | ccze -A | less -R
    }
    function tacless {
        command tac $@ | ccze -A | less -R
    }
    function head {
        if [ -t 1 ]; then
            command head $@ | ccze -A
        else
            command head $@
        fi
    }
    function tail {
        if [ -t 1 ]; then
            command tail $@ | ccze -A
        else
            command tail $@
        fi
    }
else
## We don't have the command so lets deal with these since we'd like to standardize.
    function catless  {
        cat $@ | less; echo -e "Install \033[1mccze\033[0m to get coloring!"
    }
    function tacless  {
        tac $@ | less; echo -e "Install \033[1mccze\033[0m to get coloring!"
    }

fi
Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.