Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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
1  
@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

 
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.