From adbeed7c0491d2306f60fb057301f9faf866269d Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Mon, 22 Jul 2019 12:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmac=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=B0mojave=E5=90=8E=E5=9B=A0=E8=84=9A=E6=9C=AC=E6=9D=83?= =?UTF-8?q?=E9=99=90=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E7=BB=88=E7=AB=AF=E8=BF=9B=E8=A1=8Cssh?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TP-Assist.xcodeproj/project.pbxproj | 2 +- .../apple-scripts/scripts/iterm2.applescript | 109 +++++++------- .../scripts/terminal.applescript | 133 +++++++++--------- .../src/Base.lproj/Localizable.strings | 4 +- .../tp_assist_macos/src/TP-Assist-Info.plist | 4 +- .../src/apple-scpt/iterm2.scpt | Bin 2016 -> 2098 bytes .../src/apple-scpt/terminal.scpt | Bin 2514 -> 2650 bytes .../src/zh-Hans.lproj/Localizable.strings | 2 +- 8 files changed, 134 insertions(+), 120 deletions(-) diff --git a/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj b/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj index f40084d..6222092 100644 --- a/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj +++ b/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj @@ -381,7 +381,7 @@ }; buildConfigurationList = C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "TP-Assist" */; compatibilityVersion = "Xcode 10.0"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, diff --git a/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript b/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript index 1caf314..a840cae 100644 --- a/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript +++ b/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript @@ -6,58 +6,17 @@ on scriptRun(argsCmd, argsProfile, argsTitle) end scriptRun on CommandRun(theCmd, theProfile, theTitle) - tell application "iTerm" - if it is not running then - tell application "iTerm" - activate - delay 0.5 - try - close first window - end try - end tell - - tell application "iTerm" - try - create window with profile theProfile - on error msg - create window with profile "Default" - end try - tell the current window - tell the current session - delay 0.5 - set name to theTitle - set profile to theProfile - write text theCmd - delay 0.5 - write text "" - end tell - end tell - end tell - else - --assume that iTerm is open and open a new tab - try + try + tell application "iTerm" + if it is not running then tell application "iTerm" activate - tell the current window - try - create tab with profile theProfile - on error msg - create tab with profile "Default" - end try - tell the current tab - tell the current session - delay 0.5 - set name to theTitle - write text theCmd - delay 0.5 - write text "" - end tell - end tell - end tell + delay 0.5 + try + close first window + end try end tell - on error msg - -- if all iTerm windows are closed the app stays open. In this scenario iTerm has - -- no "current window" and will give an error when trying to create the new tab. + tell application "iTerm" try create window with profile theProfile @@ -68,13 +27,59 @@ on CommandRun(theCmd, theProfile, theTitle) tell the current session delay 0.5 set name to theTitle + set profile to theProfile write text theCmd delay 0.5 write text "" end tell end tell end tell - end try - end if - end tell + else + --assume that iTerm is open and open a new tab + try + tell application "iTerm" + activate + tell the current window + try + create tab with profile theProfile + on error msg + create tab with profile "Default" + end try + tell the current tab + tell the current session + delay 0.5 + set name to theTitle + write text theCmd + delay 0.5 + write text "" + end tell + end tell + end tell + end tell + on error msg + -- if all iTerm windows are closed the app stays open. In this scenario iTerm has + -- no "current window" and will give an error when trying to create the new tab. + tell application "iTerm" + try + create window with profile theProfile + on error msg + create window with profile "Default" + end try + tell the current window + tell the current session + delay 0.5 + set name to theTitle + write text theCmd + delay 0.5 + write text "" + end tell + end tell + end tell + end try + end if + end tell + on error msg + display dialog "ERROR: " & msg + end try + end CommandRun diff --git a/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript b/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript index a61e3ab..33506c7 100644 --- a/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript +++ b/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript @@ -1,76 +1,83 @@ on scriptRun(argsCmd, argsProfile, argsTitle) - set theCmd to (argsCmd) + set theCmd to (argsCmd) set theProfile to (argsProfile) set theTitle to (argsTitle) CommandRun(theCmd, theProfile, theTitle) end scriptRun on CommandRun(theCmd, theProfile, theTitle) - tell application "Terminal" - if it is not running then - --if this is the first time Terminal is running you have specify window 1 - --if you dont do this you will get two windows and the title wont be set - activate - delay 1.0 - set newTerm to do script theCmd in window 1 - set newTerm's current settings to settings set theProfile - set custom title of front window to theTitle - - delay 1.0 - reopen - activate - tell application "System Events" to key code 36 - else - --Terminal is running get the window count - set windowCount to (count every window) - if windowCount = 0 then - --Terminal is running but no windows are open - --run our script in a new window + try + tell application "Terminal" + if it is not running then + --if this is the first time Terminal is running you have specify window 1 + --if you dont do this you will get two windows and the title wont be set + activate + delay 3.0 + set newTerm to do script theCmd in window 1 + set newTerm's current settings to settings set theProfile + set custom title of front window to theTitle + + delay 1.0 reopen activate - - do script theCmd in window 1 - - set current settings of selected tab of front window to settings set theProfile - set title displays custom title of front window to true - set custom title of selected tab of front window to theTitle - - delay 1.0 - reopen - activate - tell application "System Events" to key code 36 - + tell application "System Events" to key code 36 else - --Terminal is running and we have a window run in a new tab - reopen - activate - - tell application "System Events" - tell process "Terminal" - delay 0.5 - keystroke "t" using {command down} + --Terminal is running get the window count + set windowCount to (count every window) + if windowCount = 0 then + --Terminal is running but no windows are open + --run our script in a new window + reopen + activate + + do script theCmd in window 1 + + set current settings of selected tab of front window to settings set theProfile + set title displays custom title of front window to true + set custom title of selected tab of front window to theTitle + + delay 1.0 + reopen + activate + tell application "System Events" to key code 36 + + else + --Terminal is running and we have a window run in a new tab + reopen + activate + + tell application "System Events" + tell process "Terminal" + delay 0.5 + keystroke "t" using {command down} + end tell end tell - end tell - - reopen - activate - do script theCmd in front window - - set current settings of selected tab of front window to settings set theProfile - set title displays custom title of front window to true - set custom title of selected tab of front window to theTitle - - delay 1.0 - reopen - activate - tell application "System Events" to key code 36 - + + reopen + activate + do script theCmd in front window + + set current settings of selected tab of front window to settings set theProfile + set title displays custom title of front window to true + set custom title of selected tab of front window to theTitle + + delay 1.0 + reopen + activate + tell application "System Events" to key code 36 + + end if + + --set current settings of selected tab of front window to settings set theProfile + --set title displays custom title of front window to true + --set custom title of selected tab of front window to theTitle end if - -# set current settings of selected tab of front window to settings set theProfile -# set title displays custom title of front window to true -# set custom title of selected tab of front window to theTitle - end if - - end tell + + end tell + + on error msg + display dialog "ERROR: " & msg + end try + + end CommandRun diff --git a/client/tp_assist_macos/src/Base.lproj/Localizable.strings b/client/tp_assist_macos/src/Base.lproj/Localizable.strings index e10f545..532603b 100644 --- a/client/tp_assist_macos/src/Base.lproj/Localizable.strings +++ b/client/tp_assist_macos/src/Base.lproj/Localizable.strings @@ -3,12 +3,12 @@ TPAssist */ -"app_name" = "Teleport助手"; +"app_name" = "Teleport Assist"; //============================================= // for About Window //============================================= "version" = "Version: "; "app_full_name" = "Teleport Assist for macOS"; -"copyright" = "Copyright © 2017~2018 TP4A. All rights reserved."; +"copyright" = "Copyright © 2017~2019, tp4a.com. All rights reserved."; "visit_tp4a_website" = "Visit Teleport Website" diff --git a/client/tp_assist_macos/src/TP-Assist-Info.plist b/client/tp_assist_macos/src/TP-Assist-Info.plist index af47fa1..3231d75 100644 --- a/client/tp_assist_macos/src/TP-Assist-Info.plist +++ b/client/tp_assist_macos/src/TP-Assist-Info.plist @@ -28,8 +28,10 @@ ${MACOSX_DEPLOYMENT_TARGET} LSUIElement + NSAppleEventsUsageDescription + NSHumanReadableCopyright - Copyright © 2017~2018 TP4A. All rights reserved. + Copyright © 2017~2019, tp4a.com. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass diff --git a/client/tp_assist_macos/src/apple-scpt/iterm2.scpt b/client/tp_assist_macos/src/apple-scpt/iterm2.scpt index 431c2bf779e8e8c340ebc470140c0bf35a6bcc3a..dac4f8e2448df60bc920df0ed7e1702940d5ba8b 100644 GIT binary patch delta 253 zcmaFBze!+&6EmaqWM^h0E(VeRr}-Ip81pzLH!}N7p1{mD`7EZCHtGE_ehVo=&VkIjTp mA)G-Vf`N;HBauOJv1%3%gOq;&e`0ZR5d$Lw&#!y;)&c-Mgg6ZV delta 133 zcmV;00DAwj5a186LIVLAlS2bC1`hxX0d5GBfdf#J&jT3+ZDC_iQ%TE(g6vn^lJJZrKeeh7nuz*cd!JUSUBEba)r!j4Wl^Lf%N=s>G3gQY^Zd|yy zE?tPxohF#L@(6_ouvNI|GwsnQ z+NB-Z7De0R+g{p+`!ekPRxeNq85iNBE!so{ZO}Tc(JHObGJS-fiU`mWEz$zb(;Urm zwSpkc&@@faBuyYh%7-JC_gf7 zh%ToZS?BXiPdY2p8Y|;Lnk!eu6Q>$mVPD9bJu)qqlwlQQW?_{sWIgc1bM5CzR8dSg zRYyR2;}N6wb}?r6h-O#yF-^S~cC8%~CEPb$OQ@G=Q9O66(t`NlR!8Q`@i~s4E2)&h zYL->rG%P=lD!oHkL6}tn-7wLQG;+|v6be)99Z~oZELBDnL|_9)%y2}HuJdHm@OZmB zQr0b_KPA%?Y8p$?nY?M`2D90FM32f5Mq#+%rO7}4#Kt$vgN91ERSK$Dx8V*ijo)U} z$u!Pc)Z*IxBO#r@NTFZQDcnWn4{ZY}y{w5eotD6y}xn_Bmg39@{7^8Fi|zq*Z_ zYNy4!@a%L0CTWQ32w@VbFPR4pFREyIKa->==>x4!|wdIlo^ delta 754 zcmbu5%WD%+6vofQnPfUilT1>RRxG%vn-J|r)QuDbbs;jrnngF_?VSmvnLLjNRK zT)DgAA0RFjEcic&eK$>CNljCPfTAF{b8|d1S_m%Oc;Q~Yb2;C4ew_A5Gx_#?AgtgK z_V5t9_))Y1Pp`y5gE5HU0d`;*+qjQ=xQjcujV;`QC^m5uH*g)-a1~+@2OU>%8JA)Z zk)Eky@x-){$` zw>`yO`fGWrSf`XN@-k~d{7}+zRC?`!-xl|R=>hN;!NWh`k3v@`nlPc^Cb?=3cT2o# z9#8b}GjufE5WUcNW8I%tp=oQLGC8SLQl2kL8E7gJQ^TcWq?+S;NaC>?QFQD}cST3Nbm7xn z1Y{#aZ`gkW#@7UdzEK^`&q%>c{~XEKwRgs=IT(jozfp9CPB-G&&)MsSmFbrz8R#Tm z{+99V7b^Z0Yvg9&`Ck*yW*8(GBqtLv#$d#UVsMf{ib1-xU`JpypC7~&M?)#&e;ACM Sk;}(`x!eH>hJSXuZ+-!&=lb^m diff --git a/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings b/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings index 1c1fec3..aed4793 100644 --- a/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings +++ b/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings @@ -15,5 +15,5 @@ "about " = "关于 "; "version" = "版本:"; "app_full_name" = "Teleport助手 - macOS"; -"copyright" = "© 2017~2018 TP4A,保留所有权利。"; +"copyright" = "© 2017~2019,tp4a.com。保留所有权利。"; "visit_tp4a_website" = "访问 Teleport 网站";