If you use iTerm, you can turn on this friendly feature:
With this set, and the below script added to your $PROFILE
, new tabs will inherit the directory of the previous one.
# Set CurrentDirectory when LocationChangedAction is invoked. | |
# This allows iTerm2's "Reuse previous session's directory" to work | |
$ExecutionContext.SessionState.InvokeCommand.LocationChangedAction += { | |
[Environment]::CurrentDirectory = $pwd.Path | |
} |