我正在尝试创建一个快捷键,以打开当前文件夹中的终端。查看过一些资料后,我发现了以下代码用于创建服务(已经解决了将快捷键添加到此服务的部分)。唯一添加的内容是“; clear”,以及一些“activate”,这样它就可以显示。
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
我希望它能够按照我的意愿工作。
问题:
- 它在终端中打开两个窗口,我不知道为什么。这与添加的“activate”无关...它总是如此
- 如果我在Finder(一个文件夹)中选择一个项目,则它将打开其父目录,而我希望它打开所选文件夹
这是我第一次尝试使用Applescript,如果错误很明显,我只是看不到它
提前感谢