Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

To be clear im not looking for a workaround that will execute a change directory command on startup. I want to alter the $HOME env var so that tilde commands work and so that entering a 'cd' command will return me to that directory.

I am sure it is possible I am just not able to find the command.

I have tried setting it in my /etc/profile but it doesnt seem to work. I have tried about 4 different settings in there. The ones I can remember trying are:

$HOME = /directroy
$HOME = "/directroy"
setenv HOME /directory

I may be missing something simple but I'm unable to find a solution.

share|improve this question
    
Actually I wonder more why HOME is not already set correctly when the shell starts. If you open a new tab in Terminal, what is the result of echo $HOME? –  patrix Jun 6 '13 at 6:41
1  
@patrix I probably should have been more descriptive. It is "correctly" set to my user's home directory. I would like it to be a different directory as all of my terminal use is based out of another directory. –  Andrew Jun 6 '13 at 16:22
1  
I strongly recommend against doing that. The convention that $HOME points to your home directory is strongly embedded in Unix space and lot of shell scripts, perl scripts, binaries rely on that. You will get better results by defining something like MYROOT=/Users/andrew/base/of/all/things and then use $MYROOT where appropriate. –  patrix Jun 6 '13 at 16:57
add comment

2 Answers

up vote 1 down vote accepted

In bash (the default shell of Terminal on 10.8) the syntax:

HOME=/your/path
export HOME
share|improve this answer
add comment

Expanding on @patrix comment, change your $HOME/.bash_profile file to add the following lines:

MYROOT=/path/to/dir/you/want
export MYROOT
cd $MYROOT

This way you will get you will start your shell in /path/to/dir/you/want and using cd $MYROOT will bring you back there.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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