選択したフォルダをiTerm2で開くAppleScript

ここを参考に
http://peterdowns.com/posts/open-iterm-finder-service.html

iTerm2が見つからないから指定せよというダイアログが出てくるので
指示に従う.

on run {input, parameters}
	tell application "Finder"
		set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
	end tell
	CD_to(dir_path)
end run

on CD_to(theDir)
	tell application "iTerm2"
		activate
    try
      set _session to current session of current terminal
    on error
      set _term to (make new terminal)
      tell _term
        launch session "Default"
        set _session to current session
      end tell
    end try

    tell _session
      write text "cd " & theDir & ";clear;"
    end tell
  end tell
end CD_to

Automator上ではno inputを指定する
no inputにすると,右クリックからサービスを選択できなくなるが,
こうしておかないとKeyboard shortcutから起動できないという
謎の仕様になっている.
http://superuser.com/questions/553107/keyboard-shortcut-for-service-in-os-x-doesnt-work

キーボードショートカットは⌘+shift+↓に割り当てた.