How can I change the startup directory of my Terminal on OS X?

46,418

Solution 1

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.

Solution 2

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.

Share:
46,418
user3862503
Author by

user3862503

Updated on September 17, 2022

Comments

  • user3862503
    user3862503 over 1 year

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

  • cregox
    cregox over 13 years
    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.
  • Shinoy jose
    Shinoy jose over 7 years
    If you have "New Windows Open With: Same Working Directory" this will not work. Learned that the hard way.
  • Shinoy jose
    Shinoy jose over 7 years
    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.
  • Matej Randík
    Matej Randík almost 5 years
    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.
  • Volatil3
    Volatil3 over 4 years
    @MichaelOzeryansky What do you suggest then?
  • Volatil3
    Volatil3 over 4 years
    on opening new tab it will not retain the last opening directory
  • Shinoy jose
    Shinoy jose over 4 years
    @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/…