quentinsf Posted May 4, 2013 Share Posted May 4, 2013 I've done a little workflow for iTerm 2 users. iTerm is a great Terminal program which includes the concept of 'profiles' - a profile is a collection of terminal settings which can include things like background colour, initial command to be executed, etc. As an example, I can open a new iTerm window which will ssh into my production web server, got to the main web directory, and has a red background to warn me I can do dangerous things here. This workflow uses a Python script to extract a list of your iTerm profiles, and a bit of Applescript to tell iTerm to start up the selected one. It's my first use of a script filter, and I couldn't really find any documentation, so suggestions, corrections etc are most welcome! You can find the workflow here: http://qandr.org/quentin/software/alfred_itp Quentin Link to comment
wkoffel Posted May 6, 2013 Share Posted May 6, 2013 (edited) Check out a similar workflow I released to control Apple's Terminal. I didn't find yours until afterwards, Quentin, but looks like we had almost exactly the same needs! http://www.alfredforum.com/topic/2334-terminal-control-workflow/ Edited May 6, 2013 by wkoffel Link to comment
tolleiv Posted May 8, 2013 Share Posted May 8, 2013 (edited) Hi, great work. I had to add the "six.py" library and I had to rewrite the code slightly to get it to work: import xml.etree.ElementTree as ET import biplist import os import sys q="{query}" profile_file = os.path.join( os.environ["HOME"], "Library","Preferences","com.googlecode.iterm2.plist") pl = biplist.readPlist(profile_file) names = [nb.get('Name') for nb in pl['New Bookmarks']] if len(q) > 1: names = [n for n in names if q.lower() in n.lower()] names.sort(key=str.lower) root = ET.Element('items') for n in names: ie = ET.Element('item', valid="yes", arg=n) te = ET.Element('title') te.text = n ie.append(te) icon = ET.Element('icon') icon.text="icon.png" ie.append(icon) root.append(ie) print '<?xml version="1.0"?>' print ET.tostring(root) print "" And finally I also changed the AppleScript to open new tabs instead of new windows: on alfred_script(q) tell application "iTerm" activate set t to (last terminal) tell t launch session q end tell end tell end alfred_script Maybe this helps others. Cheers. Edited May 9, 2013 by tolleiv Link to comment
soulesschild Posted May 9, 2013 Share Posted May 9, 2013 Doesn't seem to work for me. Link to comment
trokotech Posted May 10, 2013 Share Posted May 10, 2013 It didn't work for me either. In my case the problem was that Alfred is looking for python at /usr/bin/python instead of the brew's python which is at /usr/local/bin. I fixed it by making links pointing /usr/bin/python to /usr/local/bin/python (just in case I did as well /usr/bin/python-config point to /usr/local/bin/python-config which may not be needed, I don`t know too much about python and it was for free ) BTW, nice workflow! Link to comment
soulesschild Posted May 10, 2013 Share Posted May 10, 2013 (edited) Essentially took quentin's code and re-did it a bit as well as incorporating tolleiv's modification to open it in a tab. Also imported in the alp library to help with a lot of the little stuff, it's also a modified alp library so if you try to replace it with the latest from source, it'll probably break. Includes all the necessary python files for importing so it SHOULD work without needing to install anything extra but of course it'd be nice if someone could test it. https://github.com/congalong/alfred-iterm2profiles/blob/master/iTerm2_Profiles_Modified.alfredworkflow Edited May 10, 2013 by soulesschild Link to comment
wkoffel Posted May 12, 2013 Share Posted May 12, 2013 Hey guys. Looks like we're all doing terminal control work in parallel. I wasn't sure if this workflow was being updated, and I'd had a couple requests, so I added iTerm2 support to my own ruby-based workflow. Mostly mirrors the Apple Terminal control stuff, and I think does everything this workflow does. Terminal Control Workflow http://www.alfredforum.com/topic/2334-terminal-control-workflow/ Thanks to quentinsf for the general approach, and this thread for inspiring me to go ahead and add alternate terminal emulator support. One note on a script above, you probably want "current terminal" and not "last terminal" for opening in a new tab. If the current isn't the most recently opened terminal, it'll have surprising effects. I'd love input from regular iTerm2 users (I'm an Apple Terminal guy myself) on what features would be helpful. I'm more than happy to extend my workflow to encompass other common workflow patterns just for iTerm2 users. Link to comment
soulesschild Posted May 13, 2013 Share Posted May 13, 2013 Hey guys. Looks like we're all doing terminal control work in parallel. I wasn't sure if this workflow was being updated, and I'd had a couple requests, so I added iTerm2 support to my own ruby-based workflow. Mostly mirrors the Apple Terminal control stuff, and I think does everything this workflow does. Terminal Control Workflow http://www.alfredforum.com/topic/2334-terminal-control-workflow/ Thanks to quentinsf for the general approach, and this thread for inspiring me to go ahead and add alternate terminal emulator support. One note on a script above, you probably want "current terminal" and not "last terminal" for opening in a new tab. If the current isn't the most recently opened terminal, it'll have surprising effects. I'd love input from regular iTerm2 users (I'm an Apple Terminal guy myself) on what features would be helpful. I'm more than happy to extend my workflow to encompass other common workflow patterns just for iTerm2 users. Nice! I'll check it out. Link to comment
quentinsf Posted May 17, 2013 Author Share Posted May 17, 2013 Many thanks, all, for the suggestions - I've now updated my version just to include six.py, which I hope should make it work out of the box for most people, and I've put comments in the Applescript for those who prefer tabs to windows! fleveneur 1 Link to comment
fleveneur Posted August 2, 2013 Share Posted August 2, 2013 Quentin, Thank you for making iTerm workflow. It works great. I love Alfred. Really cool App. Link to comment
javatseng Posted August 6, 2013 Share Posted August 6, 2013 Great. It works for me. Thanks. Link to comment
GFEMajor Posted February 26, 2014 Share Posted February 26, 2014 Hi, I use your workflow quite some time now. One thing. When I lunch a profile via alfred, it always opens 2 windows (or tabs). One with the default command line and one with my selected profile. Is this a config issue? If yes, how can I disable it . Link to comment
wkoffel Posted February 26, 2014 Share Posted February 26, 2014 GFE, check out this link: http://rottmann.net/2013/03/launch-iterm-2-on-startup-without-opening-a-terminal-window/ I ran into this issue with my own Terminal Workflow: http://www.alfredforum.com/topic/2334-terminal-control-workflow/ and that seems like the best solution outside of kludgy hacks in the applescript. Hi, I use your workflow quite some time now. One thing. When I lunch a profile via alfred, it always opens 2 windows (or tabs). One with the default command line and one with my selected profile. Is this a config issue? If yes, how can I disable it . Link to comment
GFEMajor Posted February 27, 2014 Share Posted February 27, 2014 Thanks for the tip . It works like charm. The only thing is, that when I start iTerm (i prefer to colse all unused apps) no window will open, but thats ok, because I mostly lunch it from alfred with itp. Link to comment
GFEMajor Posted April 15, 2015 Share Posted April 15, 2015 Hi, since the last alfred update some days ago the workflow stoped working. The profiles are still extracted, but when I click on one, nothing happens. I don't know if it is because of the new alfred version (currently using 2.7 (385)) or the latest iterm version (2.0.0.20150412). Link to comment
wkoffel Posted April 16, 2015 Share Posted April 16, 2015 Hi, since the last alfred update some days ago the workflow stoped working. The profiles are still extracted, but when I click on one, nothing happens. I don't know if it is because of the new alfred version (currently using 2.7 (385)) or the latest iterm version (2.0.0.20150412). GFE, it's unclear which workflow you are talking about here. I've tested my Terminal Control Workflow with the latest iTerm and Alfred (same versions you cited) and it's working okay for me. If it's my workflow that's giving you problems, I'm willing to take a look, but need a bit more info. Link to comment
GFEMajor Posted April 16, 2015 Share Posted April 16, 2015 (edited) Sorry, I thought it was clear because I posted it in this thread . I'm using the itermProfiles (itp) workflow by quentin Edit: Today alfred released a new version. I installed the latest version (2.7.1 (387)) and now its working again. Seems like it was an alfred bug. Thanks for the help. Edited April 16, 2015 by GFEMajor Link to comment
mrm Posted December 20, 2015 Share Posted December 20, 2015 (edited) Hi! Check this: https://github.com/miromannino/alfred-new-terminal-window It opens a new Terminal/iTerm window in the current space. Holding the alt key, the new window is also opened opened in the current frontmost Finder folder. It is really faster compared to others, really important for me since I use the terminal for almost everything! Hope it helps! Edited December 20, 2015 by miromann Link to comment
asiby Posted February 24, 2016 Share Posted February 24, 2016 If anyone lands here, please know that iTerm2 now has something called Automatic Profile Switching to show let you enter some pattern that could be found in the connection string that will trigger the selection of a profile. So no need for scripting if it was just for choosing a profile. Link to comment
mkr Posted May 2, 2016 Share Posted May 2, 2016 Hi guys:) I'm heavily using this workflow as I have to connect to several servers per ssh a day. I recently reinstalled my mac to improve development workflows etc. and so I reinstalled Alfred and iTerm. I'm using iTerm Build 2.9.20160426 and Alfred 2.8.4 (437). When I select a profile with alfred iTerm opens up, but just opens the last active tab and does nothing. Do you have any suggestions? I'm using this suggestion here to use iTerm as default Terminal in Alfred. http://www.alfredforum.com/topic/7138-custom-terminal-script-integrate-iterm-with-alfred-iterm-v3-beta-supported-updated-december-14-2015/ Really appreciate any help:) Thank you Link to comment
deanishe Posted May 2, 2016 Share Posted May 2, 2016 If it's just SSH you're after, I can't recommend Robin Breathe's SSH workflow highly enough. Link to comment
GFEMajor Posted June 23, 2016 Share Posted June 23, 2016 For me too, since update to iterm Build 3.0.2, "itp" opens up in alfred but after I select a profile, nothing happens. Any help? Link to comment
wkoffel Posted June 23, 2016 Share Posted June 23, 2016 For those of you having problems with iTerm 3.0.0+, be aware that the iTerm developers changed the way AppleScript works in the latest major revision, so pretty much all AppleScript controls (including those that are used to manage iTerm from Alfred workflows) need to be updated. I've updated my own Terminal Control workflow, it was pretty straightforward. Hopefully Quentin can update this one without any trouble, for those who prefer it. 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