Last active
February 6, 2023 11:01
-
-
Save jordonbiondo/9981411 to your computer and use it in GitHub Desktop.
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 sendtext:escape-text(s): | |
(with-temp-buffer | |
(insert s) | |
(replace-string "\\" "\\\\" nil (point-min) (point-max)) | |
(replace-string "\"" "\\\"" nil (point-min) (point-max)) | |
(buffer-substring-no-properties (point-min) (point-max)))) | |
(defun sendtext:send-iterm2(beg end) | |
(interactive "r") | |
(let ((text (buffer-substring-no-properties beg end))) | |
(start-process "send-text-iterm2-proc" "*sendtext:output*" | |
"osascript" | |
"-e" "tell app \"iTerm\"" | |
"-e" "set mysession to current session of current terminal" | |
"-e" "tell mysession to write text \"" | |
(sendtext:escape-text text) | |
"\"" | |
"-e" "end tell"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment