我正在尝试创建一个快捷键来打开当前文件夹中的终端。环顾四周,发现这段代码创建了一个服务(给这个服务添加快捷方式的部分解决了),只是添加的东西是“;清除”和一些“激活”所以它显示
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
关于Applescript 打开终端、运行命令和显示 - 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23975239/