Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you change the HOME path so that is set globally?

I like to change my HOME path to the base directory of the current project I am working on for that session, and make heavy use of opening and closing tabs, along with the cd command. Currently, every time I open up a new tab, I have to reset the HOME path to the base directory of the project I am working on. I am looking for a sort of permanent change just for that session while I am working. I can deal with having to change it back to my actual home directory at the end of work sessions if need be.

share|improve this question
up vote 1 down vote accepted

Started as an interactive shell, as when you open a tab, bash reads ~/.bash_profile. So have this rcfile cd into the directly you're focused on. You might do this with a 'focus' command:

#! /bin/bash
# usage: focus             # new bash cd's harmlessly to $HOME
# usage: focus /some/dir   # new bash cd's to /some/dir
echo "cd $1" > ~/.focus_dir

, with . ~/.focus_dir as the last line of ~/.bash_profile.

share|improve this answer
Do I have to add the focus_dir file to every project directory? – Corey Hart Oct 9 '09 at 4:17
Also, I'm working with a bashrc file, does that make a difference? – Corey Hart Oct 9 '09 at 4:19
The file is named ~/.focus_dir -- i.e., a'.focus_dir' in your home directory. Do not place this in ~/.bashrc , but place it in a new ~/.bash_profile . Please see Bash Startup Files and Tilde Expansion. – ayrnieu Oct 9 '09 at 4:50

Your Answer


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.