Applescript to open terminal, run command, and show - Not working

后端 未结 2 960
春和景丽
春和景丽 2020-12-31 23:32

I´m trying to create a keyshortcut to open terminal in current folder. Looking around, I found this code to create a service (the part of adding the shortcut to this service

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 00:11

    The do script command already opens a window in Terminal. Try it this way:

    tell application "Finder" to set theSel to selection
    
    tell application "Terminal"
     set theFol to POSIX path of ((item 1 of theSel) as text)
     if (count of windows) is not 0 then
      do script "cd " & quoted form of theFol & ";clear" in window 1
     else
      do script "cd " & quoted form of theFol & ";clear"
     end if
     activate
    end tell
    

提交回复
热议问题