Open project from Sublime Text to new tab in iTerm (not to new window)

2.3k Views Asked by At

I've been using the Terminal package to quickly open terminal from Sublime Text. Only problem is that it opens it to a new window in iTerm, not to a new tab.

Is there a way to force it to open to a new tab?

From the docs:

With the parameters argument to the open_terminal and open_terminal_project_folder commands, it is possible to construct custom terminal environments.

Can I somehow use the "parameters" in the setting to accomplish this?

Here's the default settings:

{
    // The command to execute for the terminal, leave blank for the OS default
    // On OS X the terminal can be set to iTerm.sh to execute iTerm
    "terminal": "iTerm.sh",

    // A list of default parameters to pass to the terminal, this can be
    // overridden by passing the "parameters" key with a list value to the args
    // dict when calling the "open_terminal" or "open_terminal_project_folder"
    // commands
    "parameters": []
}
2

There are 2 best solutions below

0
On

Edit the iTerm.sh in Packages/Terminal folder

if (( $RUNNING )); then
    osascript<<END
    tell application "iTerm"
        activate
        tell the first terminal
            set sess to (launch session "Default Session")
            tell sess
                write text "$CD_CMD"
            end tell
        end tell
    end tell
END

it works for me

0
On

You can config Terminal Package Setting like this:

{
    // The command to execute for the terminal, leave blank for the OS default
    // On OS X the terminal can be set to iTerm.sh to execute iTerm
    "terminal": "iTerm.sh",

    // A list of default parameters to pass to the terminal, this can be
    // overridden by passing the "parameters" key with a list value to the args
    // dict when calling the "open_terminal" or "open_terminal_project_folder"
    // commands
    "parameters": ["--open-in-tab"]
}