[英]Applescript to open terminal, run command, and show - Not working
我正在尝试创建一个快捷键来打开当前文件夹中的终端。 环顾四周,发现这段代码创建了一个服务(给这个服务添加快捷方式的部分解决了),只是添加的东西是“;清除”和一些“激活”所以它显示
on run {input, parameters}
tell application "Finder"
activate
set myWin to window 1
set theWin to (quoted form of POSIX path of (target of myWin as alias))
tell application "Terminal"
activate
tell window 1
activate
do script "cd " & theWin & ";clear"
end tell
end tell
end tell
return input
end run
它不像我想要的那样工作。
麻烦:
这是我第一次尝试 Applescript 所以如果错误很明显我就是看不到它
提前致谢
do script
命令已经在终端中打开了一个窗口。 试试这个方法:
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
我更喜欢重新打开方法...
tell application "Finder" to set currentFolder to target of front Finder window as text
set theWin to currentFolder's POSIX path
tell application "Terminal"
if not (exists window 1) then reopen
activate
do script "cd " & quoted form of theWin & ";clear" in window 1
end tell
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.