Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

I want to put a .bashrc file in a directory where my application is located, to set up path variables accordingly independent of the location of the directory at the moment. At the same time, I want to be able to run the application right away, without having to source a shell file to set the path every time. Therefore I figured I could use .bashrc which is executed when the non-login terminal is started.

If I do put it in the proper .bashrc in the home directory, I would have to give an absolute path which I want to avoid.

Is there a way to have something like .bashrc but not in home directory (ie a shell that is executed when terminal is started?)

share|improve this question

You can use the --rcfile "file" bash option, that read "file" instead of /etc/bash.bashrc and ~/.bashrc.

You can create a launcher for gnome-terminal that in turns launch bash with that option.

share|improve this answer
Hm, but I still want to read ~/.bashrc, I want it to read it and 'file' additionally. Also, giving it 'file' sort of defeats the point since I was hoping to do it location-independent and without giving an absolute path. – FSchmidt Mar 30 '12 at 12:46
@FSchmidt: for the first request, you can add . ~/.bashrc as the first line of file. For the second request: how do you think bash could find your file, if you do not want to say where is? – enzotib Mar 30 '12 at 12:57
Good question! I was hoping there would be a bash option that tells it to run, for example, any files named '.bashrc' in all subdirectories. – FSchmidt Mar 30 '12 at 13:00

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.