ここから本文です
Emacs+Mac OS Xで現在バッファパスにterminalでcdする
表題のとおり。
git ci -aはおまけ。なくてもいいです。
;; thx http://superuser.com/questions/466619/open-new-terminal-tab-and-execute-script
;; thx http://qiita.com/ganmacs/items/cfc5f9c2213a6a9e6579
(defun cd-on-terminal (&optional command)
"Change directory to current buffer path by Terminal.app. COMMAND is execute after cd."
(interactive)
(util/execute-on-terminal
(concat (format "cd %s" default-directory) command)))
(defun util/execute-on-terminal (command)
"Change directory to current buffer path by Terminal.app. COMMAND."
(interactive "MCommand: ")
(do-applescript
(format "tell application \"Terminal\"
activate
tell application \"System Events\" to keystroke \"t\" using command down
repeat while contents of selected tab of window 1 starts with linefeed
delay 0.01
end repeat
do script \"%s\" in window 1
end tell"
command)))
(global-set-key (kbd "C-c d") 'cd-on-terminal)
(global-set-key (kbd "C-c g") (lambda () (interactive) (cd-on-terminal " && git ci -a")))

