I want my terminal to always start at a certain directory instead of home. How can I do this?
-
1I've answered this on SO: stackoverflow.com/a/39255856/359532– Michael OzeryanskyAug 31, 2016 at 17:41
-
@Sheehan Scott's answer should be the selected answer, as it is a specific feature within the Terminal app just for this sort of thing, and easy to find.– BBaysingerMar 29, 2021 at 5:53
4 Answers
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.
-
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.– cregoxOct 5, 2010 at 16:04
-
1If you have "New Windows Open With: Same Working Directory" this will not work. Learned that the hard way. Aug 31, 2016 at 17:20
-
-
@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
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
Try this:
export HOME=DESTINATION_DIRECTORY
without any double quotation marks. To verify, type env
and look out for HOME in the list.
-
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