Skip to content

Instantly share code, notes, and snippets.

@samukasmk
Created July 17, 2014 17:55
Show Gist options
  • Save samukasmk/9dff4d4e8b2870f92ddd to your computer and use it in GitHub Desktop.
Save samukasmk/9dff4d4e8b2870f92ddd to your computer and use it in GitHub Desktop.
Call your specific command to the current session of the current terminal
-- by: Samuel Maciel Sampaio [2014-17-07]
-- contact: samukasmk@gmail.com
-- goal: call your specific command to the current session of the current terminal
-- Special Thanks to Stefan van den Oord, 2010-12-29
-- and https://code.google.com/p/iterm2/wiki/AppleScript
tell application "iTerm"
activate
try
set _session to current session of current terminal
on error
set _term to (make new terminal)
tell _term
launch session "Default"
set _session to current session
end tell
end try
tell _session
write text "newline > /dev/null 2>&1"
tell application "System Events" to keystroke "k" using {command down}
write text "PUT YOUR SPECIFIC COMMAND HERE!"
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment