查看 在这里打开终端 。它可能与“Open Command Window Here”最相似。我用了 >cdto 这非常相似,但这似乎在处理Spaces方面要好一点......但并不完美。
>cdto
它有什么非常好的能力“ 检测应用程序启动时的按键事件,并使用它们来修改脚本的行为 “当按住⌘键调用时,允许脚本在最前面的终端窗口中打开一个新选项卡。整洁的技巧。
还要注意PCheese的答案;它可能对重型终端用户更有用!
OSX 10.6上的AppleScript中存在一个错误。 (2个终端窗口打开)。 我通过在激活后添加close命令来修复此问题。这关闭了第一个终端窗口。
on run tell application "Finder" try activate set frontWin to folder of front window as string set frontWinPath to (get POSIX path of frontWin) tell application "Terminal" activate close do script with command "cd \"" & frontWinPath & "\"" end tell on error error_message beep display dialog error_message buttons ¬ {"OK"} default button 1 end try end tell end run
此外,您可以使用命令-C从查找程序中复制项目,跳转到终端(例如使用Spotlight或QuickSilver)类型“cd”并只需使用命令-v粘贴
如果您安装Big Cat Scripts( http://www.ranchero.com/bigcat/ )您可以添加自己的上下文菜单(右键单击)项目。我不认为它带有一个开放式终端这里的苹果,但我使用这个脚本(我不记得,如果我自己写的,或者从其他人的例子中取消):
on main(filelist) tell application "Finder" try activate set frontWin to folder of front window as string set frontWinPath to (get POSIX path of frontWin) tell application "Terminal" activate do script with command "cd \"" & frontWinPath & "\"" end tell on error error_message beep display dialog error_message buttons ¬ {"OK"} default button 1 end try end tell end main
类似的脚本也可以为您提供右键单击文件的完整路径,这对我来说更有用。
我主要使用这个功能:
cf() { cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')" }
您还可以为脚本分配快捷方式,如下所示。
重用现有选项卡或创建新窗口(终端):
tell application "Finder" to set p to POSIX path of (insertion location as alias) tell application "Terminal" if (exists window 1) and not busy of window 1 then do script "cd " & quoted form of p in window 1 else do script "cd " & quoted form of p end if activate end tell
重用现有选项卡或创建新选项卡(终端):
tell application "Finder" to set p to POSIX path of (insertion location as alias) tell application "Terminal" if not (exists window 1) then reopen activate if busy of window 1 then tell application "System Events" to keystroke "t" using command down end if do script "cd " & quoted form of p in window 1 end tell
始终创建一个新选项卡(iTerm 2):
tell application "Finder" to set p to POSIX path of (insertion location as alias) tell application "iTerm" if exists current terminal then current terminal else make new terminal end if tell (launch session "Default") of result to write text "cd " & quoted form of p activate end tell
与10.7中添加的服务相比,前两个脚本有两个优点:
我发现作为替代方案不可或缺的应用程序是 DTERM ,实际上在你的应用程序中打开一个迷你终端。此外,它适用于那里的所有东西 - Finder,XCode,PhotoShop等。
如果像我一样关闭Finder工具栏,此服务会在每个文件夹的上下文菜单中添加一个项目: http://blog.leenarts.net/2009/09/03/open-service-here/
这也允许您打开在Finder树视图中看到的任何文件夹。
这个:
https://github.com/jbtule/cdto#cd-to
这是一个小型应用程序,您拖动到Finder工具栏,图标非常适合。它适用于终端,xterm(在X11下),iterm。
从Mac OS X Lion 10.7开始,终端将此功能完全包含在服务中。与大多数服务一样,默认情况下会禁用这些服务,因此您需要启用此功能才能使其显示在“服务”菜单中。
系统偏好设置>键盘>快捷方式>服务
启用 的 文件夹的新终端 强> 。还有 的 文件夹中的新终端选项卡 强> ,这将在最前面的终端窗口中创建一个选项卡(如果有的话,否则它将创建一个新窗口)。这些服务适用于所有应用程序,而不仅仅是Finder,它们可以在文件夹上运行,也可以在文本中选择绝对路径名。
您甚至可以为它们分配命令键。
服务显示在每个应用程序菜单的“服务”子菜单中,并显示在上下文菜单中(按住Control键单击或右键单击文件夹或路径名)。
该 的 文件夹的新终端 强> 服务将变得活跃 的 选择文件夹时 强> 在Finder中。您不能简单地打开文件夹并“就地”运行服务。返回父文件夹,选择相关文件夹,然后通过“服务”菜单或上下文菜单激活该服务。
此外,如果将文件夹(或路径名)拖到终端应用程序图标上,Lion终端将打开一个新的终端窗口,您还可以拖动到现有窗口的选项卡栏以创建新选项卡。
最后,如果将文件夹或路径名拖到选项卡上(在选项卡栏中)并且前台进程是shell,它将自动执行“cd”命令。 (拖动到选项卡中的终端视图只会自己插入路径名,就像旧版本的终端一样。)
您也可以从命令行或shell脚本执行此操作:
open -a Terminal /path/to/folder
这是将文件夹/路径名拖到终端应用程序图标上的命令行。
在相关的说明中,Lion Terminal还提供了用于查找手册页的新服务: 的 在终端中打开手册页 强> 在新的终端窗口中显示所选的手册页主题,以及 的 在终端中搜索man页面 强> 对所选文本执行“apropos”。前者还理解手册页引用(“open(2)”),手册页命令行参数(“2 open”)和手册页URL(“x-man-page:// 2 / open”)。
我为finder工具栏创建了一个包含3个应用程序的包。 另外两个应用程序:
有关更多信息,请参见此处 http://nslog.de/posts/71
有一个非常漂亮和苗条的更新版本 的 在这里打开终端 强> 发布者 vgm64 和 d0k 。改变是由 詹姆斯大卫低 。他发布了新版本 他的网站 。只需下载OpenTerminalHere.zip,解压缩,将软件包移动到Library / Scripts文件夹,然后将其从那里拖到Finder工具栏。
它的特别之处在于它 的 始终打开一个新选项卡 强> 如果Terminal.app窗口已经打开。很有用!我还注意到应用程序按钮的样式更适合Snow Leopard Finder.app样式而不是发布的cdto 节录 没有。