老东西曾经说过:
cat也是猫,猫当然要哈气
在shell的配置文件中添加一个cat函数来hook原本的cat命令,在正常执行cat命令的基础上加上哈气功能
.bashrc/.zshrc中:
cat() {
if [ $# -gt 0 ]; then
local file_count=0
for arg in "$@"; do
if [ -f "$arg" ]; then
command cat "$arg"
((file_count++))
else
command cat "$arg"
fi
done
if [ $file_count -gt 0 ]; then
echo -e "\\n哈!"
fi
else
command cat
fi
}config.fish中:
function cat
if count $argv > /dev/null
set file_count 0
for arg in $argv
if test -f "$arg"
command cat "$arg"
set file_count (math $file_count + 1)
else
command cat "$arg"
end
end
if test $file_count -gt 0
echo -e "\\n哈!"
end
else
command cat
end
end添加完毕后记得执行下面的命令来立即应用更改
source ~/.bashrc
source ~/.zshrc
source YOUR_FISH_CONFIG_PATH下载install.sh并执行,会自动添加到当前用户的终端配置文件中
当变成豪猫不再哈气的时候,只需要去到终端的配置文件中手动删除即可