I am trying to make an apple script that launches Alacritty and tmux. I have all the parts except the script runs while I'm running Alacritty and I would like it to exit soon after running (in both cases, where a tmux session exists and when it doesn't).
set t to (time of (current date))
do shell script "nohup /Applications/Alacritty.app/Contents/MacOS/alacritty -e /usr/local/bin/tmux attach || tmux new -s general > /dev/null 2>&1 &"
if (time of (current date)) < t + 1 then
do shell script "nohup /Applications/Alacritty.app/Contents/MacOS/alacritty -e /usr/local/bin/tmux new -s general > /dev/null 2>&1 &"
end if
This works as I'd hoped when there isn't a tmux session, but it runs until I quit Alacritty.
I think the solution will be related to job control in AppleScript, but I can't figure it out. I essentially need a way to wait for a second or two and then test if it is running or something.
question from:
https://stackoverflow.com/questions/65559759/process-not-running-in-background 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…