我正在尝试连续运行以下命令:
osascript -e 'tell application "System Events" to set visible of every application process to false'
是否存在具有以下方法的某种命令?
repeat "enter command here"
如果不是,我该怎么做?
答案1
使用一个简单的while
循环,sleep
介于两者之间:
while true; do osascript -e 'tell application "System Events" to set visible of every application process to false'; sleep 1; done
如果你有自制,安装watch
(brew install watch
),然后调用:
watch -n1 osascript -e 'tell application "System Events" to set visible of every application process to false'
…每秒运行一次。
答案2
如果你不想继续分叉新的 osascript 进程,你可以使用 AppleScript 的 repeat 语句:
osascript -e repeat -e 'tell app "System Events" to set visible of processes to false' -e 'delay 5' -e 'end repeat'