有人能帮我把这个脚本改成自动 YES 吗?是吗?
我不需要或不想确认是,我只是想将是传递到 shell 快捷方式中。
cat << "EOF" >> ~/.zshrc
#Kill apps that match string
function kill-apps() {
IFS=$'\n'
red=$(tput setaf 1)
normal=$(tput sgr0)
if [ -z "$1" ] || [ "$1" = "--help" ]; then
printf "%s\n" "Usage: kill-apps string"
return 0
fi
printf "%s\n" "Finding apps that match “$1”…"
sleep 1
processes=($(pgrep -afil "$1"))
if [ ${#processes[@]} -eq 0 ]; then
printf "%s\n" "No apps found"
return 0
else
printf "%s\n" "${processes[@]}"
printf "$red%s$normal" "Kill found apps (y or n)? "
read -r answer
if [ "$answer" = "y" ]; then
printf "%s\n" "Killing found apps…"
sleep 1
for process in "${processes[@]}"; do
echo $process | awk '{print $1}' | xargs sudo kill 2>&1 | grep -v "No such process"
done
printf "%s\n" "Done"
return 0
fi
fi
}
EOF
source ~/.zshrc;
kill-apps adobe
更多背景信息
在 Mac 快捷方式应用程序功能中将其作为快捷方式运行并返回参数 y 或 n ?我想要做的就是给它一个 yes 命令
从此开始 -https://www.youtube.com/watch?app=desktop&v=mSibcNslSK8&t=547s
和这个
https://www.reddit.com/r/AdobeZii/comments/s2rr7z/delete_adobe_creative_cloud_and_stop_all_adobe/
预先感谢您的任何帮助
答案1
这与命令一起工作:
echo y | kill-apps adobe