From 3478bb0edb7ed10c1fd965ce63e03fe3d12ad1a8 Mon Sep 17 00:00:00 2001 From: fofolee Date: Wed, 18 May 2022 21:19:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=97=B6=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E4=BC=9A=E6=9C=89=E5=BC=B9=E5=87=BA=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E7=BB=88=E7=AB=AF=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/preload.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/plugin/preload.js b/plugin/preload.js index 5553486..8e552f9 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -258,14 +258,20 @@ let getCommandToLaunchTerminal = (cmdline, dir) => { cd = dir ? `cd ${dir.replace(/ /g, '\\\\ ')} &&` : ''; command = fs.existsSync('/Applications/iTerm.app') ? `osascript -e 'tell application "iTerm" - create window with default profile - tell current session of current window to write text "clear && ${cd} ${cmdline}" - end tell'` : + if application "iTerm" is running then + create window with default profile + end if + tell current session of first window to write text "clear && ${cd} ${cmdline}" + activate + end tell'` : `osascript -e 'tell application "Terminal" - do script "clear && ${cd} ${cmdline}" - activate - end tell'`; - + if application "Terminal" is running then + do script "clear && ${cd} ${cmdline}" + else + do script "clear && ${cd} ${cmdline}" in window 1 + end if + activate + end tell'`; } return command; } @@ -680,4 +686,4 @@ window.quickcommandHttpServer = () => { run, stop } -} \ No newline at end of file +}