Skip to content

Instantly share code, notes, and snippets.

@ivey
Created September 17, 2008 21:14
Show Gist options
  • Save ivey/11310 to your computer and use it in GitHub Desktop.
Save ivey/11310 to your computer and use it in GitHub Desktop.
emacs lisp function to open a Terminal.app window in default-directory
(defun tell-terminal (commands)
"Use osascript to tell Terminal.app to do stuff"
(interactive)
(shell-command
(concat
"osascript"
(mapconcat
'(lambda (command) (concat " -e 'tell application \"Terminal\" "
command "'"))
commands ""))))
(defun terminal-there (dir)
"Open Terminal.app and change working directory."
(interactive)
(tell-terminal (list
(concat "to do script \"cd " dir "\"")
"to activate")))
(defun terminal-here ()
"Open Terminal.app in `default-directory'."
(interactive)
(terminal-there default-directory))
(global-set-key "\C-c\C-t" 'terminal-here)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment