ctwise Posted February 27, 2013 Share Posted February 27, 2013 I like the terminal support in Alfred (prefacing commands with '>') but it always opens a new terminal window. I would prefer that the commands execute in the current terminal window. Luckily there's a new 'Custom' option for handling terminal commands. The following was taken almost verbatim from the iTerm site (http://code.google.com/p/iterm2/wiki/AppleScript) and will execute terminal commands in the active iTerm2 shell. It will launch iTerm2 if it isn't currently running. on alfred_script(q) tell application "iTerm" activate try -- We don't need error messages set miniaturized of windows to false end try 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 q end tell end tell tell application "System Events" set visible of process "iTerm" to true end tell end alfred_script Link to comment
kuriharak93 Posted March 14, 2013 Share Posted March 14, 2013 This is awesome, thank you! Link to comment
vitor Posted March 19, 2013 Share Posted March 19, 2013 Maybe you could help me with something, as I’m trying to do something similar. I’d like commands passed through Alfred to run in a new iTerm2 window, regardless of whether it is already running or not. The issue is that if it’s not already running, Alfred opens two windows. I’ve been making some experiments, and it does not seem to work. It succeeds if run from within Applescript Editor, but not from Alfred’s custom option for terminal commands. I’ve posted the script I’m working with (based on yours) on the forum http://www.alfredforum.com/topic/1180-extra-tab-is-open-when-using-iterm2/#entry5666. Any help on how to achieve that would be appreciated. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now