Displaying a table of shell aliases
The best practice for dealing with temporary files is simply not to use them in the first place.  Many things can go wrong with temporary files:


Lack of permissions to write to a directory
Lack of disk space
Read-only filesystem
File or symlink already exists
File or symlink didn't exist when you checked, but got created immediately after, in a race condition
Script crashed, such that it created a temporary file but didn't get a chance to clean it up


Though there are ways to mitigate these risks, I see no reason to use a temporary file here at all.  For that matter, cat and the first grep are also superfluous.

#!/bin/sh

awk -F= '
    BEGIN {
        TABLE_FMT = "%-18s | %-58s"
        row = sprintf(TABLE_FMT, "ALIAS", "COMMAND");
        print row;
        gsub(".", "-", row);
        print row;
    }
    END {
        print row;
    }

    /^alias/ {
        gsub(/\s+/, " ", $0);  # Condense consecutive whitespace
        printf TABLE_FMT "\n", $1, $2;
    }
' &lt; "$HOME/.zshrc" | grep --color '#.*\|$'


I can't tell for sure, but it looks like the second grep is meant to highlight comments.  Unfortunately, it actually ends up stripping out all uncommented lines, including the header and footer.



Instead of parsing the $HOME/.zshrc configuration file, you might want to query the live alias definitions in the current shell instead.  In that case, you should write a shell function that processes the output of the bare alias command.