wlabarron Posted January 7 Posted January 7 Using Alfred 5.5.1 [2273] on macOS Sequoia 15.2. Steps to reproduce: Check that the Terminal app is not running. Launch Alfred and type `>ls ~` (or any other terminal command), then select the "Run command in Terminal" action. Expected outcome: The Terminal app opens and runs the `ls ~` command. Actual outcome: Terminal app launches (i.e. appears in the Dock) but no windows open. If you run the command from Alfred a second time, a window opens and the command runs. This issue has been going on for at least a month now - possibly longer, I'm afraid I've not been keeping track properly, nor can I remember if there was a specific update to macOS or Alfred coinciding with the bug happening. I am able to reproduce the issue consistently.
vitor Posted January 7 Posted January 7 Welcome @wlabarron, What does your Alfred Preferences → Features → Terminal look like?
wlabarron Posted January 7 Author Posted January 7 Hi @vitor, thank you! Prefix: > Application: Terminal
vitor Posted January 7 Posted January 7 What happens if you do run the command, and instead of running it a second you click the Terminal icon in the Dock? Does the window have the command in there or not?
wlabarron Posted January 7 Author Posted January 7 Clicking Terminal in the Dock opens a blank window.
vitor Posted January 7 Posted January 7 Change it to Custom and use this code: on alfred_script(q) tell application "Terminal" if running then do script "" activate do script q in window 1 end tell end alfred_script What’s the behaviour now? Also, what’s your Mac model?
wlabarron Posted January 7 Author Posted January 7 Still seeing the same behaviour with that AppleScript. Running on a 2021 MacBook Pro.
vitor Posted January 7 Posted January 7 on alfred_script(q) tell application "Terminal" if running then do script "" activate activate delay 1 do script q in window 1 end tell end alfred_script How about that?
wlabarron Posted January 7 Author Posted January 7 That script has the same result, but I've got a little closer to the problem: If I have an open Terminal window, then quit Terminal, and run the command in Alfred, everything works as expected. If I have an open Terminal window, close that window, then quit Terminal, I end up with the bug I described originally. So it seems to be an issue with opening Terminal when it is not launching a restored session.
vitor Posted January 7 Posted January 7 That’s a good insight, my next suggestion was precisely going to be that there might be something funky going on with your Terminal settings. I can’t reproduce your issue, so check what you can change. One thing which might work for you is: on alfred_script(q) tell application "Terminal" activate do script "" do script q in window 1 end tell end alfred_script But that may leave you with an extra window in some situations. It might be possible to write the exact AppleScript for your situation but that’s extra hard without being able to reproduce your problem.
wlabarron Posted January 7 Author Posted January 7 That latest script seems to work okay, so I'll put that in as a workaround for now - thank you! There's not much in the way of Terminal settings that seem useful - it's set to open new window at startup and I can't see much else relevant. I suppose it's just a case of trying again on the next macOS!
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