iTerm2 zsh oh-my-zsh open tab with same directory

3

1

Hi i just installed iTerm2 and tried to open a tab with the same directory as the tab that open it.

I tried Open a new tab in the same directory answer but still can't get the directory working.

It worked fine in terminal.app but when im using iTerm it's not work anymore

ahmy

Posted 2012-05-30T08:03:55.313

Reputation: 167

Answers

6

It does work for me. Are you sure your .zshrc has the osx plugin loaded? Check for the existence of the function with:

$ type tab
tab is a shell function

Then, in your terminal, simply run the command

tab

This will execute the appropriate line in the tab() function defined by the osx plugin. If it works for Terminal.app, it should also work for iTerm2.


In order to map this command to a custom keyboard shortcut like CmdShiftR, do the following. Open up Automator.app and create a new Service. Set it to receive No Input from iTerm.app and drag Run AppleScript from the left to the editing pane.

tell application "iTerm"
    tell current terminal
        tell current session
            write text "tab"
        end tell
    end tell
end tell

That should look like this:

Save it under Open new Tab with zsh or similar. Now, under System Preferences » Keyboard » Keyboard Shortcuts, under Services, assign a keyboard shortcut.

Note that not all keyboard shortcuts are available, and you can't just override CmdT since this is a built-in one.

slhck

Posted 2012-05-30T08:03:55.313

Reputation: 182 472

Note: You need to actually type tab into the terminal to create a new tab. Not through Shell » New Tab or ⌘T – slhck – 2012-05-30T10:35:35.767

3

You don't need a custom command anymore...

Preferences > Profiles > [Profile Name] > General > Working Directory > "Reuse previous tab's directory"

Source: https://code.google.com/p/iterm2/issues/detail?id=420#c14

SillyTerminal

Posted 2012-05-30T08:03:55.313

Reputation: 31

1

I solved this by adding -l to Command in my Profile settings. fix iterm

Michael Forrest

Posted 2012-05-30T08:03:55.313

Reputation: 111