Go2Shell and AppleScript
給Finder加上一個打開當前路徑的終端的功能
有兩種實現(xiàn):
Go2Shell App 和 AppleScript擴展:
AppleScript 實現(xiàn) Go2Shell 一樣的可視化打開方式
一、Go2Shell
1. 安裝
1、Go2Shell官方安裝 (推薦,因為AppStore下載的版本太低,無法打開iTerm2 -坑-)
http://zipzapmac.com/Go2Shell

至此就可以打開shell,不過僅僅是打開系統(tǒng)默認的終端shell
2. 進入 Preferences 的方式
open -a Go2Shell --args config

iTerm2 不能打開當前文件所在目錄()
3. 官網(wǎng)下載效果圖(多了個 >_< 能直接打開配置)

二、配置 Automator 方法
1. 新建 Automator 服務
打開Automator,選擇新建,選擇服務
2. 設置 Automator 服務
1、 服務接受設為沒有輸入,位置設為Finder(訪達)

2、 從左側(cè)的資源庫中找出 運行 AppleScript,拖到右側(cè),然后保存為Open iTerm Here

復制以下代碼
代碼意思是將當前最前面的Finder地址如果獲取不到,則返回桌面地址然后通知iTerm的第一個窗口新建標簽并跳到這個目錄去
on run {input, parameters}
tell application "Finder"
set pathList to (quoted form of POSIX path of (folder of the front window as alias))
set command to "clear; cd " & pathList
end tell
tell application "System Events"
-- some versions might identify as "iTerm2" instead of "iTerm"
set isRunning to (exists (processes where name is "iTerm")) or (exists (processes where name is "iTerm2"))
end tell
tell application "iTerm"
activate
set hasNoWindows to ((count of windows) is 0)
if isRunning and hasNoWindows then
create window with default profile
end if
select first window
tell the first window
if isRunning and hasNoWindows is false then
create tab with default profile
end if
tell current session to write text command
end tell
end tell
end run
3、點擊運行就能在 iTerm2 中打開當前目錄

4、 設置快捷鍵
打開系統(tǒng)設置,再去鍵盤設置里改一下快捷鍵,然后就可以快速在Finder中通過iTerm打開當前目錄了

三、擴展
Automator 創(chuàng)建應用
使用的 Automator AppleScript 時候就在想為什么使用創(chuàng)建的服務,好吧,換個思路創(chuàng)建個應用,嘗試著以Go2Shell的方式按住command鍵拖到文件夾上,結(jié)果和Go2Shell實現(xiàn)的效果一樣OK,對 Automator 的使用充滿期望~~
