在 Mac 终端上为 grep 创建别名

Create alias for grep on Mac terminal

我通常运行这个命令来验证文件的 SHA1 散列

shasum filename.txt |grep -E --color '<hash value>|$'

所以我为它创建了一个别名:

alias shacheck='check_sha_hash'

check_sha_hash() {
    shasum  |grep -E --color '|$'
}

但没有帮助:

shacheck myfile.txt 3a5b106e413ab621ad13788e5ceab8ba1d974cb8
3a5b106e413ab621ad13788e5ceab8ba1d974cb8  myfile.txt --> didn't colorized the hash

我做错了什么?

像这样尝试强制彩色输出:

check_sha_hash() {
    shasum  | grep -E --color=always "|$"
}

请参阅this question了解更多信息。