Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created April 4, 2010 05:57
Show Gist options
  • Save yaotti/355152 to your computer and use it in GitHub Desktop.
Save yaotti/355152 to your computer and use it in GitHub Desktop.
;; open the current (file's) directory in Terminal.app
(defun mac-open-terminal ()
(interactive)
(let ((dir ""))
(cond
((and (local-variable-p 'dired-directory) dired-directory)
(setq dir dired-directory))
((stringp (buffer-file-name))
(setq dir (file-name-directory (buffer-file-name))))
)
(do-applescript
(format "
tell app \"Terminal\"
do script with command \"cd %s\" in window 1
activate
end tell" dir))
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment