6

Now that I figured out how to set iTerm2 as the ssh:// URL handler, I'd like iTerm2 to respond to an ssh URL by opening a new window instead of opening a new tab in an existing window. Is this possible?

1
  • 2
    You can drag any tab out of an iTerm 2 window to create a new window.
    – Ian C.
    Oct 24, 2011 at 0:13

2 Answers 2

4

I was curious about the same problem. After reviewing the source code, I found in iTerm2 v1.0.0.20111020 is hard-coded to open a new session as a tab if a session already exists, when it receives nearly any "launch this URL with a handler" command.

My Xcode and Objective-C skills are still rather weak, but if you want to give it a shot I believe the problem is related to the source file iTermController.m. On lines 789 to 870 the launchBookmark:withURL method has the following code:

// Where do we execute this command?
BOOL toggle = NO;
if (theTerm == nil) {
    [iTermController switchToSpaceInBookmark:aDict];
    term = [[[PseudoTerminal alloc] initWithSmartLayout:YES
                                             windowType:[aDict objectForKey:KEY_WINDOW_TYPE] ? [[aDict objectForKey:KEY_WINDOW_TYPE] intValue] : WINDOW_TYPE_NORMAL
                                                 screen:[aDict objectForKey:KEY_SCREEN] ? [[aDict objectForKey:KEY_SCREEN] intValue] : -1] autorelease];
    [self addInTerminals: term];
    toggle = [term windowType] == WINDOW_TYPE_FULL_SCREEN;
} else {
    term = theTerm;
}

id result = [term addNewSession: aDict withURL: url];

I suspect that when theTerm == nil, addNewSession works as expected by launching a new window, since one is currently not running. Perhaps you can modify the code to force the first block to always run, regardless of theTerm's contents.

I hope this helps!! .. It may be worth filing a bug report or contacting the author if you're still having problems.

3
  • Submitted a feature request: code.google.com/p/iterm2/issues/detail?id=1567 Oct 31, 2011 at 15:01
  • 1
    +1 on Google Code. I would purpose that there be an option to disable tabs entirely, as I personally never use them. However this may be overkill as the only time I've ever encountered a "forced tab" is by this use-case. So if upstream can fix this specific bug I'll be happy too :)
    – adamrmcd
    Oct 31, 2011 at 19:05
  • I can't believe this was logged in 2011 but it's still happening now! I can't find an option in iterm to disable the new tab behaviour. Am I missing something? Sorry for resurrecting such an old post.
    – btongeorge
    Oct 25, 2023 at 11:27
0

Using the latest version of iTerm2, under Preferences > Advanced > Windows there's this option:

Open files in new windows, not new tabs

Set this to Yes to have scripts open in a new window.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .