Skip to content

Instantly share code, notes, and snippets.

@bravelincy
Last active April 17, 2017 02:50
Show Gist options
  • Save bravelincy/70bcb840197e6d1af0c72556627991bb to your computer and use it in GitHub Desktop.
Save bravelincy/70bcb840197e6d1af0c72556627991bb to your computer and use it in GitHub Desktop.
fi script content of alfred
on alfred_script(q)
tell application "Finder"
set pathList to (quoted form of POSIX path of (folder of the front window as alias))
set command to "clear; cd " & pathList
end tell
tell application "System Events"
-- some versions might identify as "iTerm2" instead of "iTerm"
set isRunning to (exists (processes where name is "iTerm")) or (exists (processes where name is "iTerm2"))
end tell
tell application "iTerm"
activate
set hasNoWindows to ((count of windows) is 0)
if isRunning and hasNoWindows then
create window with default profile
end if
select first window
tell the first window
if isRunning and hasNoWindows is false then
create tab with default profile
end if
tell current session to write text command
end tell
end tell
end alfred_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment