Skip to content

Instantly share code, notes, and snippets.

@shoyuf
Last active September 2, 2020 03:43
Show Gist options
  • Select an option

  • Save shoyuf/8b2821a48cfe7183680eeed6b5331516 to your computer and use it in GitHub Desktop.

Select an option

Save shoyuf/8b2821a48cfe7183680eeed6b5331516 to your computer and use it in GitHub Desktop.
open iTerm 2 and exec script on Alfred
on alfred_script(q)
tell application "System Events" to set isRunning to exists (processes where name is "iTerm2")
if isRunning then
tell application "iTerm2" to set hasWindow to exists (windows)
if hasWindow then
tell application "iTerm2"
tell current window to create tab with default profile
tell current session of current window to write text q
end tell
else
tell application "iTerm2" to create window with default profile
tell application "iTerm2"
tell current session of current window to write text q
end tell
end if
else
launch application "iTerm"
end if
end alfred_script
@shoyuf
Copy link
Author

shoyuf commented Mar 16, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment