When I have a Terminal window open, ⌘N opens a new one.
Is there any way to get the current directory in the new window to automatically be the same as it was on the window where I pressed ⌘N?
To accomplish this within a new window, go to Preferences within Terminal.app.
Within the General tab, you can adjust the behavior (you likely want to select Same Working Directory) for both new windows and new tabs.
If you hit ⌘T
in the Terminal, it will open another tab, which will be in the same directory as before :-).
You can easily switch between the tabs using keyboard shortcuts too like
- ⌘-Shift-[ and ⌘-Shift-]
Enjoy!
The problem is that Terminal doesn't know anything about what directory you're in.
But the shell does! So you can type:
open -a /Applications/Utilities/Terminal.app .
and it will open a new window on your current directory.
If you want to do this a lot, put the following in ~/.bashrc:
alias openhere='open -a /Applications/Utilities/Terminal.app .'
Then, all you will have to type is openhere
to do the same thing.
/etc/bashrc
.
Commented
Mar 24, 2015 at 10:30
alias openhere='open -a /Systems/Applications/Utilities/Terminal.app .'
for Big Sur OS :)
In Zshell, I need to do both this setting
and I need this in my .zshrc
# http://superuser.com/a/315029/4952
# Set Apple Terminal.app to resume directory... still necessary 2018-10-26
if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]] {
function chpwd {
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
chpwd
}
I've tried without one or the other to no avail.