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.