Applescript 打开终端、运行命令和显示 - 不工作 [英] Applescript to open terminal, run command, and show - Not working
本文介绍了Applescript 打开终端、运行命令和显示 - 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个快捷键来打开当前文件夹中的终端.环顾四周,发现这段代码创建了一个服务(给这个服务添加快捷方式的部分解决了),只是添加的东西是;清除"和一些激活"所以它显示
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 is solved), only added things are the "; clear" and some of the "activate" so it shows
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
它不能如我所愿.
问题:
- 它在终端打开了两个窗口,不知道为什么.它没有什么可使用添加的激活"...它一直不认为
- 如果我在 finder(一个文件夹)上选择一个项目,它会打开它的父目录,我会喜欢它打开选定的文件夹
这是我第一次尝试 Applescript,所以如果错误很明显,我就是看不到它
this is my very first try with Applescript so if the error is obvious i just can't see it
提前致谢
推荐答案
do script
命令已经在终端中打开了一个窗口.试试这个方法:
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
这篇关于Applescript 打开终端、运行命令和显示 - 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文