9

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 :

enter image description here

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.

  1. Every tab is the same than the others: if I do a cd ~/foo/, then the other tabs will go into foodirectory.

  2. 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.

Update 1

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:

command /bin/bash launched for new tab

I tried also to build the binary iTerm2 from the sources but issue remains.

Update 2

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.

Update 3

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 :

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 ?

Update 4

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.

halfer
  • 19,824
  • 17
  • 99
  • 186

3 Answers3

2

The OP already answered the question in Update 4, but in case anyone jumps right to the answers, the solution was to update the Key Mappings and create two new entries - CMD+SHIFT+LEFT & CMD+SHIFT+RIGHT - with assigned actions of Previous Tab and Next Tab, respectively.

These entries can be created in Preferences -> ${Your Profile} -> Keys, and then clicking on the + icon near the Presets... button.

sudo soul
  • 1,504
  • 13
  • 20
0

enter image description here

Do you see the all-pane input icon in the upper right? Command-Shift-I to toggle it. (that is a capital i)

Boomer
  • 464
  • 3
  • 10
  • this doesn't work, whatever I toggle it or not when I do a CMD+T, all the new tabs are clones. –  Oct 31 '19 at 20:51
  • Only other thing I could think to try is clearing all the setting: `defaults delete com.googlecode.iterm2` ...if that doesn't change the behavior back to default then I'm not sure. – Boomer Nov 01 '19 at 11:40
  • I tried your command but this doesn't change anything, same cloning between the 2 tabs ... I have just upgraded from Mojave to Catalina and the bug remains : Does this bug occur often on recent MacOS Macbook version ? Regards –  Nov 04 '19 at 21:14
  • I've also upgraded to Catalina. Been using iTerm/iTerm2 on different OSX versions for a long time, never had this issue. In your settings you're executing /bin/bash instead of just using a login shell, which is why I recommended clearing your settings back to default. I still think there must be some setting or script causing this and not the application itself, but if it's affecting default settings I don't know what to tell you. – Boomer Nov 07 '19 at 12:43
  • Thanks for your remark ... How can I totally clean up the installation of iTerm2 ? Are there hidden files to remove (like ~/.iterm2) ? Even by doing a `sudo port uninstall iterm2`, I can still launch iTerm2, I don't understand why the executable is not removed (I remenber to have donwloaded a zip file from official iTerm2 website)... If you had another suggestions ? –  Nov 07 '19 at 13:41
  • That line of code I gave you before is from the iTerm documentation to remove all settings, deleting the application would be the only other step to clean it totally. Why are you installing with ports rather than the prepackaged? https://iterm2.com/downloads/stable/iTerm2-3_3_6.zip – Boomer Nov 07 '19 at 14:06
  • It's possible you've installed multiple versions and now have setting affected by both – Boomer Nov 07 '19 at 14:09
  • yes, I should have mixed multiple versions, I am going to clean `macport` package and associated config files and try to setup the .zip archive, I keep you informed, Regards –  Nov 07 '19 at 14:12
  • I show you a screen capture of the `profile section`and the necessity or not to set a CMD+T shortcut to open a new tab on this `profile section`. I have also change the `/bin/bash` to `login shell` option. It seems that `iTerm2` has already this shortcut integrated by default. I tried to set another shortcut like CMD+A or other nut issue remains. –  Nov 07 '19 at 14:35
0

Sounds like you have Broadcasting enabled. To check:

Toolbar > Shell > Broadcast Input > Send input to current Session Only

Benoit C.
  • 1
  • 2
  • Do you use iTerm2 on your macOS ? and if yes, did you manage to disable the broadcast input ? I mean no clone new tab opened with CMD+T ? –  Nov 04 '19 at 21:16
  • Yes I use new tabs and splits a ton, not having the issue you're describing. Do you have any screen or tmux configs in your .bash_profile by any chance? The other difference in my settings is that I use login shell, not /bin/bash – Benoit C. Nov 07 '19 at 15:41
  • Thanks, Could you explain me please how to open a new tab not cloned with screen or tmux ? I mean to find an alternative to my issue. –  Nov 07 '19 at 16:27
  • Did you end up figuring it out ? If not I'll take another look. Also curious to know what is causing that behavior. – Benoit C. Jan 19 '20 at 10:03
  • yes, I managed to do what I wanted. You can see the solution into my **UPDATE4** –  Jan 19 '20 at 10:12