2

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?)

1 Answer 1

3

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.

3
  • 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, 2012 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, 2012 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, 2012 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .