Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Terminal at last open directory?

Every time I open my Terminal application at work it starts from a clean slate (e.g. it opens from the ~/ directory). But at home on my laptop my Terminal always remembers the last directory I was in (and all the commands on the screen) and displays them to me.

I'm trying to get this to happen when I'm at work but I can't find any information on it (I've no idea why or how my laptop managed to set itself to work that way?).

The only thing I've found out is that I can change the preferences so the Terminal executes a particular command when the app is started up, but that's not quite what I want (simply because I'm not sure what command I would run to get the Terminal to go to the directory I was looking at when I had the Terminal open last).

Any ideas?

Thanks!

like image 435
Integralist Avatar asked Mar 26 '12 12:03

Integralist


People also ask

How do I go to a specific directory in terminal?

cd or change directoryThe cd command allows you to move between directories. The cd command takes an argument, usually the name of the folder you want to move to, so the full command is cd your-directory . Now that we moved to your Desktop, you can type ls again, then cd into it.

How do I go back to the previous directory in code or terminal?

You can try it out yourself by opening a Terminal window, navigating somewhere within the file system, then immediately switching directories to another location. Now just type cd – to switch back to the prior location, and cd – again to switch back to the original location.


1 Answers

Since you're using Lion, it should do that automatically.

You might have disabled the Resume functionality systemwide or in Terminal.

Make sure it's enabled systemwide. You can also try to manually enable it for Terminal:

defaults write com.apple.Terminal NSQuitAlwaysKeepsWindows -bool true
like image 102
Sindre Sorhus Avatar answered Sep 25 '22 21:09

Sindre Sorhus