简体   繁体   中英

Sourcing from a different bashrc

My original .bashrc script is currently used to run model runs. Now I need to manipulate it to compile a completely new model.

My question is, if I save my original .bashrc, as something such as .bwwbashrc, do I need to manipulate the file in some way so it is able to be read or recognized as the .bashrc when I source it within my scripts?

original sourcing

source /home/tsee/.bashrc

What I think the new sourcing would be. (after creating .bwwbashrc)

source /home/tsee/.bwwbashrc

Just not sure if I need to save it with a certain extension or edit the executable in some sort of way.

Nope, you can name it whatever you want. Executable bit isn't required either.

If you aren't aware of it, the bash --login option might be of interest to you.

To complement Matt's correct answer, I'd also point out that you can start a new Bash shell that sources your alternative file instead of .bashrc at start-up.

bash --rcfile .bwwbashrc

From the bash man page:

--rcfile file

Execute commands from file instead of the standard personal initialization file ~/.bashrc if the shell is interactive (see INVOCATION below).

If you want to replace your current shell (with commands and settings from .bashrc ), you can run

exec bash --rcfile .bwwbashrc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM