【问题标题】:Process not running in background进程未在后台运行
【发布时间】:2021-01-04 08:37:06
【问题描述】:

我正在尝试制作一个启动 Alacritty 和 tmux 的苹果脚本。在运行 Alacritty 时,除了脚本之外的所有部分都在运行,并且我希望它在运行后很快退出(在这两种情况下,tmux 会话存在和不存在时)。

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

当没有 tmux 会话时,这就像我希望的那样工作,但它会一直运行到我退出 Alacritty。

我认为解决方案将与 AppleScript 中的作业控制有关,但我无法弄清楚。我基本上需要一种方法来等待一两秒钟,然后测试它是否正在运行。

【问题讨论】:

    标签: applescript tmux alacritty


    【解决方案1】:

    好的,我想出了另一种方法:

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

    这结合了两者。

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-30
      • 1970-01-01
      • 2011-07-14
      相关资源
      最近更新 更多