Create New Tab Sessions with the same working Directory
18,511
Solution 1
One of the options for a profile is which directory to use when creating a session with that profile. The default is to use your home directory, but you can change that to use the previous directory instead. You can change this setting in the default profile (allowing you to continue using ⌘-T), or you can create a new profile which uses this setting, and assign a different keyboard shortcut to create a session with that profile.
Solution 2
Preferences->Profiles->Working Directory->Reuse previous session's directory
Author by
StanleyZheng
Full stack developer. Always working on new projects.
Updated on June 20, 2022Comments
-
StanleyZheng about 2 years
Often in workflow you are working within a directory and then need to create a second terminal or session to the same directory.
TAB 1 #~/home cd really #~/home/really cd long #~/home/really/long cd filepath #~/home/really/long/filepath node filepath #session now occupied #new TAB #CTR + T #~/home #I want to be in the same filepath
is there a setting somewhere to do this?
-
StanleyZheng over 10 yearsAwesome thanks! The Short Version, For Iterm2 Iterm-> Preferences-> profiles -> working directory -> Reuse Previous Session Directory
-
StanleyZheng over 10 yearstried this in Terminal and iTerm2 doesn't seem to work. @chepner gave a good solution for iterm2 users
-
Amrit Dhungana over 10 yearsI have use oh-my-zsh too. Have you use it ? Its no T its D
-
chepner over 10 yearsThis just splits the window, with the new pane using the same profile. Whether that pane keeps the same directory depends on the profile setting.
-
Sgnl over 8 yearsfor more control: Iterm2 Iterm-> Preferences-> profiles -> Advanced Config [edit button] -> now you can choose a different action for panes or tabs or windows.
-
DianeZhou over 4 yearsThis feature is broken in iTerm2-3.3.7(The most latest one). Is there any other solution?
-
chepner over 4 yearsThe "Reuse previous session's directory" option is still available in 3.3.8beta.
-
Darragh Enright over 4 yearsFantastic! I cannot believe I didn't bother looking this up before, so useful. I'm using 3.3.9 and you can specify advanced behaviour for when you open a new tab, window or split pane.
-
alper about 4 yearsDoes it also work if I connected over
ssh
? @chepner