I have switched from default terminal on MacOS Mojave to iterm2
. I have an issue about the opening of a new tab from the current tab.
Indeed, I would like to be in the same path than the previous current tab.
For this, I did the classical procedure, i.e to go to iterm2
preferences and Profile
and choose Reuse previous session's directory
for new tab :
Then, the issue is that once tab opened, all the other tabs are affected and change from their old path to the path of the new tab: I don't understand what happens and which option to use to prevent this behavior.
Every tab is the same than the others: if I do a cd ~/foo/
, then the other tabs will go into foo
directory.
Result worse: if I edit with vim
a file in one tab, if I do a cd ~/foo/
in another tab, then the tab associated to the edited file disappears is clearing this edition and shows the same windows than the tab where I did cd ~/foo/
: very strange.
I want to keep all the current path for all others tabs except for the new one which must be the same than the previous one from which I do a CMD+T.
I saw on different forums this issue sometimes occurs.
From what I have seen, it seems that I have to find a way to create a new session when I do the shortcut CMD+T to get another tab independent from the current one (from which I do CMD+T).
But unfortunately, I didn't find how to create a new session in iTerm2
(inside the iTerm2 - Preferences - profile
, I could execute a script that creates this new session). From the moment, you can see the command (/bin/bash
that I launch when I open a new tab:
I tried also to build the binary iTerm2
from the sources but issue remains.
I tried to use a little apple script to force a new session to be created from current window:
tell application "iTerm2"
tell current window
create tab with profile "Terminology2"
end tell
end tell
(where Terminology2 is a duplicate of profile Terminology (default profile).
But always the same issue, the 2 tabs are not independent: each command in one of 2 is executed on the another one.
I keep on trying a solution: for this I removed the macport
package and hidden files and directory ~/.iTerm2/
.
So I downloaded the iTerm2 zip
archive from iTerm2 official website.
Here's a screen capture of my profile :
Is shortcut key
necessary in this profile to open new tabs : the issue seems to come from this option since it may not concern the shortcut for a new tab ? CMD+T is already a shortcut for opening an independent tab, isn't it ?
Solution finally found. Coming from classic MacOS terminal, I was used to do a shortcut CMD+Shift+-> or CMD+Shift+<- to change of tab.
But by chance, I tried simply the shortcut CMD+-> or CMD+<- and so was able to switch between 2 tabs independent.
So this was an error of beginner into iTerm2's world since I was used to apply old classical shortcut of default terminal.
If someone else makes the same mistake, they will know that it is just a configuration issue of shortcut.
Do you see the all-pane input icon in the upper right? Command-Shift-I to toggle it. (that is a capital i)