Created
October 10, 2013 18:05
-
-
Save mcav/6922811 to your computer and use it in GitHub Desktop.
Executes the most recent iTerm command from right within Emacs. Useful for unit testing, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun exec-last-iterm-command () | |
(interactive) | |
(do-applescript | |
(concat | |
"set currentApp to (path to frontmost application as text)\r" | |
"tell application \"iTerm\" to activate\r" | |
"tell application \"System Events\"\r" | |
" delay 0.1\r" | |
" keystroke \"p\" using control down\r" | |
" keystroke return\r" | |
"end tell\r" | |
"tell application currentApp to activate\r"))) | |
(global-set-key (kbd "M-RET") 'exec-last-iterm-command) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The reason I didn't just tell iTerm (which supports applescript) to write "!!" is because zsh doesn't actually execute the command when you type that. I didn't want to rely on specific terminal options.