16

I want my terminal to always start at a certain directory instead of home. How can I do this?

2

4 Answers 4

24

I'm not sure if theres a cleaner way, but adding cd path/to/directory in your .bash_profile in your home directory should automatically change your directory to what you specify.

4
  • As Randolph pointed out, there a cleaner way to change the home directory: stackoverflow.com/questions/145321/… difference of doing it so is that it also changes what ~ points to, as anything else pointing to "home" and not just the startup place. So, your answer is the most appropriate one for this question with this choice of words.
    – cregox
    Oct 5, 2010 at 16:04
  • 1
    If you have "New Windows Open With: Same Working Directory" this will not work. Learned that the hard way. Aug 31, 2016 at 17:20
  • @MichaelOzeryansky What do you suggest then?
    – Volatil3
    Oct 9, 2019 at 14:45
  • @Volatil3 It's been a while, but since answers like these didn't work for me I came up with my own solution: stackoverflow.com/questions/5696757/… Oct 9, 2019 at 14:54
12

In Terminal.app's preferences, in the "Settings" tab, select the style of your terminal (probably Basic: the default), then go to the "Shell" pane and put cd /any/directory/you/want in the run command box. This will automatically change directory when you open a new terminal.

1
  • 1
    on opening new tab it will not retain the last opening directory
    – Volatil3
    Oct 9, 2019 at 14:49
0

See this StackOverflow question.

-1

Try this:

export HOME=DESTINATION_DIRECTORY

without any double quotation marks. To verify, type env and look out for HOME in the list.

2
  • This does work, but since it changes my HOME, using cd will bring it back there and my prompt shows ~ for when I'm in the new HOME. Just letting others know. Aug 31, 2016 at 17:26
  • This is highly likely to cause problems. It's common for other scripts and applications to put documents and config files in the user's home folder, which you've just reassigned. If you just want to save yourself some typing when you open the terminal, this isn't the way to do it. Jul 29, 2019 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.