在 MacOS 上打开 Ghostty 总是 新标签打开,换成新窗口又不能进入路径。所以使用 AppleScript 来处理这个:
AppleScript
set targetDir to do shell script "p=@rfpath;
if [ -d \"$p\" ]; then
printf '%s' \"$p\";
else
dirname \"$p\";
fi"
tell application "Ghostty"
set cfg to new surface configuration
set initial working directory of cfg to targetDir
set win to new window with configuration cfg
activate
end tell