stuartcryan Posted July 27, 2015 Share Posted July 27, 2015 (edited) Hi Team, I seem to be having a bit of an issue that has cropped up in the last few weeks, I am not sure exactly when it started but the symptoms are this: 1. When I try to execute a terminal command with '.< command >' or a workflow tries to execute a terminal command... if I don't already have iTerm open, nothing happens at all. 2. If I manually open iTerm and have it running in the background... everything runs fine. This seems to occur across all three of my Macs. Versions: iTerm2 2.1.1 OSX: 10.10.4 Alfred: 2.7.1 (387) I have had a look and turned on all info for one of the flows and it does not error out at all, this seems to execute successfully: [iNFO: alfred.workflow.input.keyword] Processing output 'alfred.workflow.action.terminalcommand' with arg '' But strangely iTerm2 is never opened. It seems the iTerm2 program is now just called iTerm in my Applications folder, not sure if this has affected things at all (or if it always was). I have also checked the system console and no errors seem to be outputted to any system logs during the time I was testing. Look forward to hearing from you. Cheers, Stuart Update: All righty and now I have updated the scripts... made them more awesome and even added one for iTerm 2.9 https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/tree/master Not sure the best way to publish this but if anyone has any issues let me know and I will try to tweak the scripts further. Cheers, Stuart Edited August 5, 2015 by stuartcryan Link to comment Share on other sites More sharing options...
Andrew Posted July 29, 2015 Share Posted July 29, 2015 Hi Team, I seem to be having a bit of an issue that has cropped up in the last few weeks, I am not sure exactly when it started but the symptoms are this: 1. When I try to execute a terminal command with '.< command >' or a workflow tries to execute a terminal command... if I don't already have iTerm open, nothing happens at all. 2. If I manually open iTerm and have it running in the background... everything runs fine. This seems to occur across all three of my Macs. Versions: iTerm2 2.1.1 OSX: 10.10.4 Alfred: 2.7.1 (387) I have had a look and turned on all info for one of the flows and it does not error out at all, this seems to execute successfully: [iNFO: alfred.workflow.input.keyword] Processing output 'alfred.workflow.action.terminalcommand' with arg '' But strangely iTerm2 is never opened. It seems the iTerm2 program is now just called iTerm in my Applications folder, not sure if this has affected things at all (or if it always was). I have also checked the system console and no errors seem to be outputted to any system logs during the time I was testing. Look forward to hearing from you. Cheers, Stuart iTerm's AppleScript has changed over time, as has the application name (now simply named iTerm.app), so for now, you'll need to update the terminal AppleScript yourself in Alfred's Features > Terminal. Select the "Custom" option and then use something similar to one of the scripts in here: https://gitlab.com/gnachman/iterm2/wikis/Applescript or https://iterm2.com/applescript.html depending on the version you are currently using! Hope this helps (for now, at least). Cheers, Andrew Link to comment Share on other sites More sharing options...
stuartcryan Posted July 30, 2015 Author Share Posted July 30, 2015 (edited) Hi Andrew thanks for that, With those links I was able to come up with the following which seems to works around it for the time being for the current v2 of iTerm: on alfred_script(q) tell application "iTerm" activate set myterm to (make new terminal) tell myterm launch session "Default Session" tell the last session write text q end tell end tell end tell end alfred_script Edited July 30, 2015 by stuartcryan Link to comment Share on other sites More sharing options...
stuartcryan Posted July 31, 2015 Author Share Posted July 31, 2015 (edited) OK once iTerm decided to update itself to 2.1.1 it stopped working again. SO here is a new version and even BETTERER this works around the age old issue of the default terminal always opening [edit] helps if I post the full thing. I might throw this together into a git repo as I am sure it will need updating on a more regular basis on is_running(appName) tell application "System Events" to (name of processes) contains appName end is_running on alfred_script(q) if is_running("iTerm") then run script " on run {q} tell application \"iTerm\" activate tell the first terminal set mysession to (launch session \"Default Session\") tell mysession write text q end tell end tell end tell end run" with parameters {q} else run script " on run {q} tell application \"iTerm\" activate tell the first terminal tell the last session write text q end tell end tell end tell end run" with parameters {q} end if end alfred_script Edited July 31, 2015 by stuartcryan Link to comment Share on other sites More sharing options...
stuartcryan Posted July 31, 2015 Author Share Posted July 31, 2015 All righty and now I have updated the scripts... made them more awesome and even added one for iTerm 2.9 https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/tree/master Not sure the best way to publish this but if anyone has any issues let me know and I will try to tweak the scripts further. Cheers, Stuart Link to comment Share on other sites More sharing options...
stuartcryan Posted August 5, 2015 Author Share Posted August 5, 2015 I know I am probably talking to myself here... so I will just say, new version released, check out the github repo for details https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred Vero and deanishe 2 Link to comment Share on other sites More sharing options...
deanishe Posted August 5, 2015 Share Posted August 5, 2015 Nah, this thread helped me fix my own iTerm AppleScripts stuartcryan 1 Link to comment Share on other sites More sharing options...
stuartcryan Posted August 6, 2015 Author Share Posted August 6, 2015 Nah, this thread helped me fix my own iTerm AppleScripts WOOHOO haha glad to hear it, nice to know I can help out (if you have any suggested modifications to the scripts please let me know... I just threw together pretty basic ones...). Have to say I am stoked with the 2.9 one now though... not getting the double terminal opening /dances Link to comment Share on other sites More sharing options...
cands Posted August 9, 2015 Share Posted August 9, 2015 WOOHOO haha glad to hear it, nice to know I can help out (if you have any suggested modifications to the scripts please let me know... I just threw together pretty basic ones...). Have to say I am stoked with the 2.9 one now though... not getting the double terminal opening /dances Thanks this helped me solve issues with iterm as well! stuartcryan 1 Link to comment Share on other sites More sharing options...
stuartcryan Posted August 11, 2015 Author Share Posted August 11, 2015 No worries at all seeing as this has proven useful for a couple of people, I have decided to formally publish the scripts in a better location at http://www.alfredforum.com/topic/7138-custom-terminal-script-correct-iterm-behaviour-for-alfred/. I will keep that thread up to date with any changes to the scripts etc (to act as sort of a notification for the community, almost treating it like a workflow). Glad I have been able to help you out and thanks go out to Andrew for pointing me in the right direction. Cheers, Stuart Andrew 1 Link to comment Share on other sites More sharing options...
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