chrispoole Posted July 2, 2018 Share Posted July 2, 2018 I want to find a folder with Alfred, then use the "open terminal here" action. Issue is that I don't want a new Terminal window opening; I want my existing Terminal window to have the `cd ...` command issued. Is that possible? Link to comment
Tsunami Posted July 2, 2018 Share Posted July 2, 2018 (edited) I use iTerm instead of Terminal, so I'm not sure if this code catches all conditions, but you can do this: Open Alfred Preferences, click the Features tab and click Terminal / Shell in the sidebar. Set Application to Custom and paste this script in the large textfield: on alfred_script(q) tell application "Terminal" if exists window 1 then do script q in window 1 else do script q end if activate end tell end alfred_script Close Alfred Preferences to save the changes. Note that when you run a Terminal command manually with Alfred (by prefixing it with ">"), it will now also run in the existing window. Edited July 2, 2018 by Tsunami chrispoole 1 Link to comment
chrispoole Posted July 2, 2018 Author Share Posted July 2, 2018 Perfect! I've used a bit of AppleScript I've been using with Emacs for years: on alfred_script(q) tell application "Terminal" try if (count of windows) is 0 then do script q else do script q in window 1 end if activate on error beep end try end tell end alfred_script That works a treat: if I already have a Terminal window open it'll send the commands there, otherwise it'll create a new window. Tsunami 1 Link to comment
deanishe Posted July 2, 2018 Share Posted July 2, 2018 22 minutes ago, Tsunami said: Open Alfred Preferences, click the Features tab and click Terminal / Shell in the sidebar That makes all Terminal Commands run in the current window, not just the "Open Terminal Here" File Action. That may or may not be what @chrispoole is after. I thought it was worth mentioning, in any case. Link to comment
Tsunami Posted July 2, 2018 Share Posted July 2, 2018 Correct, I noted that at the end of my post. Link to comment
deanishe Posted July 2, 2018 Share Posted July 2, 2018 12 minutes ago, Tsunami said: Correct, I noted that at the end of my post. Right. I wasn't clear. There's also the Terminal Command element in workflows. That is also affected. Link to comment
chrispoole Posted July 2, 2018 Author Share Posted July 2, 2018 Yeah that's all fine, thanks for confirming though @deanishe. This solution suits me perfectly, at least right now. 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