最も簡単な方法は、エイリアスを使用することです。この簡単な例はあなたのために働くはずです:
これにより、引数に tempus を指定して heroku コマンドを実行できなくなります
function protect_heroku {
# use grep to determine if the bad string is in arguments
echo "$*" | grep tempus > /dev/null
# if string is not in arguments
if [ $? != 0 ]; then
# run the protected command using its full path, so as not to trigger alias
/path/to/heroku "$@"
else
# get user confirmation
echo -n Are you sure \(y/n\)?' '
read CONFIRM
if [ "$CONFIRM" = y ]; then
# run the protected command using its full path
/path/to/heroku "$@"
fi
fi
}
# This is the key:
# This alias command means that 'heroku' from now refers
# to the function protect_heroku, rather than /bin/heroku
alias heroku=protect_heroku
このコードを bash プロファイル ~/.profile に入力し、ログアウトしてから再度ログインします。今後、bash は、誤って tempus で heroku を実行することから保護します。