13
3
I want my terminal to always start at a certain directory instead of home. How can I do this?
13
3
I want my terminal to always start at a certain directory instead of home. How can I do this?
21
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.
1If you have "New Windows Open With: Same Working Directory" this will not work. Learned that the hard way. – Michael Ozeryansky – 2016-08-31T17:20:10.160
As Randolph pointed out, there a cleaner way to change the home directory: http://stackoverflow.com/questions/145321/how-to-set-os-x-terminals-default-home/145330#145330 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 – 2010-10-05T16:04:07.913@MichaelOzeryansky What do you suggest then? – Volatil3 – 2019-10-09T14:45:59.297
@Volatil3 It's been a while, but since answers like these didn't work for me I came up with my own solution: https://stackoverflow.com/questions/5696757/set-the-default-directory-in-mac-terminal/39255856#39255856
– Michael Ozeryansky – 2019-10-09T14:54:47.67710
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.
on opening new tab it will not retain the last opening directory – Volatil3 – 2019-10-09T14:49:40.853
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.
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. – Michael Ozeryansky – 2016-08-31T17:26:44.920
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. – Justin Morgan – 2019-07-29T21:39:58.843
I've answered this on SO: http://stackoverflow.com/a/39255856/359532
– Michael Ozeryansky – 2016-08-31T17:41:29.253