applescripttmuxalacritty

Process not running in background


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.


Solution

  • Okay I figured out another way:

    do shell script "nohup /Applications/Alacritty.app/Contents/MacOS/alacritty -e /usr/local/bin/tmux new -A -s general > /dev/null 2>&1 &"
    

    This combines both.