TextMate作为Mac coder 最常用的 开发工具之一,当我们想用 TextMate打开当前所在目录或当前选中的文件时,如果希望可以快捷操作的话,除了可以自己使用快捷键外,还可以通过自定义 Finder Toolbar 为其添加一个 Open in textmate 的 button。效果图如下:
其原理是通过获取当前选中的文件或当前所在目录,然后将其具体路径在作为open 参数传递给 textmate。以下是 AppleScript的实现:
-- Opens the currently selected Finder files, or else the current Finder window, in TextMate. Also handles dropped files and folders.
-- By Henrik Nyh
-- script was clicked
on run
tell application "Finder"
if selection is {} then
set finderSelection to folder of the front window as string
else
set finderSelection to selection as alias list
end if
end tell
tm(finderSelection)
end run
-- script was drag-and-dropped onto
on open (theList)
tm(theList)
end open
-- open in TextMate
on tm(listOfAliases)
tell application "TextMate"
open listOfAliases
activate
end tell
end tm
可以看出 AppleScript 的代码可读性还是很不错的,比如 set finderSelection to folder of the front window as string ,获取当前窗体的路径将其转化为string 并赋值给finderSelection变量,看上去就是一句完整英文句子。
其App文件已经找打包好了在附件中,直接下载解压后并将APP文件其拖拽至Finder 中的 ToolBar 位置即可,如果自己想给改变其图标,可以右键该 App ,选择 "Show Package Contents" ,在 Resources 可以看到图标,并可将其替换。其中代码在 Scripts目录中,有兴趣可以看看,并可以通过这种方式可以自定义更多的方便快捷的 ToolBar Button,比如附件中另外一个实用的button,打开当前目录的终端("Open Terminal Here" )。
- 大小: 58.6 KB
分享到:
相关推荐
在ToolBar上实现添加滚动条和下拉框,并且实现了两者的关联。
在ToolBar工具栏居中添加自定义控件。
MFC工具栏ToolBar按钮添加下拉菜单
VC在Dialog中使用Menu和Toolbar 并为工具栏添加工具提示
VBA 范例90 使用Toolbar控件添加工具栏.xlsm
在MFC工具栏ToolBar上面添加Edit控件,使用create函数创建,超简单几句话就搞定
Firefox的Torrent搜索工具栏,使用户能够以http://torrent-finder.info/形式搜索170多个顶级洪流站点和跟踪器。 它允许用户搜索单个站点,搜索一页上的所有站点或在Firefox中打开站点。
一个VB6.0的toolbar的使用示范,toolbar是很好用的控件
如何往IE工具条添加按钮 Adding Toolbar Buttons往IE上添加工具条 用VC在IE浏览器的工具条上添加命令按钮.zip
osx-finder-toolbar-apps 要添加到 OSX Finder 工具栏的工具
在基于对话框Dialog的应用程序中如何添加用图片做成的工具栏Toolbar
toolbar例子
Toolbar的实现,弹出框的实现
android下导航栏ToolBar的使用示例,包含添加菜单、菜单事件、Title、图标等功能
微软树型菜单TOOLBAR。
Toolbar基本使用及Toolbar+ListView实现滑动变色
rebar + toolbar 界面rebar + toolbar 界面rebar + toolbar 界面rebar + toolbar 界面
Android 5.0的时候就用Toolbar替代了ActionBar,而ActionBarActivity又被AppCompatActivity替代,那么使用方法就是引入Toolbar设置到Activity中 一个应用的几乎所有界面都需要头部app bar,为了能够方便各个界面方便...
Android toolbar 使用详解,一个不错的学习toolbar的例子,里面包括各种toolbar用法