Skip to content

Instantly share code, notes, and snippets.

@ndreas
Created January 8, 2011 10:21
Show Gist options
  • Save ndreas/770735 to your computer and use it in GitHub Desktop.
Save ndreas/770735 to your computer and use it in GitHub Desktop.
Changes to the Quicksilver iTerm plugin to make it work with iTerm
The changes were made twice in the binary "iTerm Module" since the script is embedded twice. I just opened the binary in Vim and searched for "activate" to find the scripts.
Changes:
- Create a new window instead of a tab (I prefer it that way)
- Launch the default session instead of creating a new session
- Disable the bash-commands since it overrode my default shell, zsh
The strange indentation in the modified file is due to the fact that the binary b0rks if the string length is changed. If it does not work, try removing or adding characters in the script. Quicksilver generates an error message on startup (for example in Console.app) if there is something wrong with the binary.
tell application "iTerm"
activate
set aterm to (make new terminal)
tell aterm to launch session "Default"
tell aterm to set asession to current session
--to exec command "/bin/bash --login"
tell asession to write text "%@"
end tell
tell application "iTerm"
activate
set aterm to (first terminal)
tell aterm to set asession to (make new session at the end of sessions)
tell asession to exec command "/bin/bash --login"
tell asession to write text "%@"
end tell
@mankoff
Copy link

mankoff commented Mar 1, 2012

When I make this change, the file size remains the same: 56700 bytes, so I think I did it correctly. But QS won't load it. Console has the following error:

    /Users/mankoff/Library/Application Support/Quicksilver/PlugIns/com.blacktree.Quicksilver.YTiTermPlugIn.33.qsplugin/Contents/MacOS/iTerm Module: unknown file type, first eight bytes: 0xFA 0xED 0xFE 0x07 0x00 0x00 0x00 0x03
2012-02-29 20:03    Quicksilver[31632]  Failed loading bundle NSBundle </Users/mankoff/Library/Application Support/Quicksilver/PlugIns/com.blacktree.Quicksilver.YTiTermPlugIn.33.qsplugin> (not yet loaded)

@ndreas
Copy link
Author

ndreas commented Mar 3, 2012

I did some testing and I cant reproduce your error. First of all, I had a different path to my plugin, so I downloaded the plugin from here: http://qsapp.com/plugins.php to make it match your path. I applied the changes from the script above and everything worked fine for me.

However, I suspect from your error message that whichever editor you used to change the binary might have written some bad data at the start of the file. If dump the start of the file I get the following:

> hexdump iTerm\ Module | head
0000000 ca fe ba be 00 00 00 02 00 00 00 12 00 00 00 00
0000010 00 00 10 00 00 00 5e 0c 00 00 00 0c 00 00 00 07
0000020 00 00 00 03 00 00 70 00 00 00 6d 7c 00 00 00 0c
0000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

I get the same on an unchanged binary. I suggest you look at what your file looks like in a hex editor and see if the start of the file matches the error message you get. If that's the case, try using an editor that does not modify the head of the file in any way.

@mankoff
Copy link

mankoff commented Mar 3, 2012

I have the same first few bytes according to hexdump. I'm using emacs which, I think, edits hex without changing the file other than the bytes edited. Any chance you can share you binary?

@skurfer
Copy link

skurfer commented Mar 5, 2012

Are you sure this is easier than a rewrite? :-)

@ndreas
Copy link
Author

ndreas commented Mar 6, 2012

@mankoff: http://dl.dropbox.com/u/1434942/iterm-mod.tar.bz2 see if that one works for you.

@skurfer: a rewrite would be best, I'll take a look at it. I've skimmed through the code for the Terminal plugin and it doesn't seem that difficult to make a corresponding plugin for iTerm2. I'll just have to learn Objective C :)

@mankoff
Copy link

mankoff commented Mar 7, 2012

Works great. Not sure why my edits didn't. Thank you very much!

@ndreas
Copy link
Author

ndreas commented Mar 24, 2012

@mankoff
Copy link

mankoff commented Mar 24, 2012

I type a folder name, hit tab, and type 'iterm' and nothing shows up with this plugin. With the previous one, I could select "Go to directory in iTerm".

@ndreas
Copy link
Author

ndreas commented Mar 25, 2012

I only used the Terminal commands with iTerm set as the provider, so the plugin only supported those commands. However, I've updated the plugin to supply iTerm-specific commands: https://github.com/ndreas/iTerm2-qsplugin/downloads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment