简体   繁体   English

从不同的bashrc采购

[英]Sourcing from a different bashrc

My original .bashrc script is currently used to run model runs. 我最初的.bashrc脚本当前用于运行模型运行。 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? 我的问题是,如果我将原始的.bashrc保存为.bwwbashrc之类的文件,是否需要以某种方式处理该文件,以便在我从脚本中获取该文件时可以将其读取或识别为.bashrc?

original sourcing 原始采购

source /home/tsee/.bashrc

What I think the new sourcing would be. 我认为新的采购方式将会是。 (after creating .bwwbashrc) (在创建.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. 如果您不了解它,那么bash --login选项可能会让您感兴趣。

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. 为了补充Matt的正确答案,我还指出,您可以在启动时启动一个新的 Bash Shell,该外壳将提供替代文件而不是 .bashrc

bash --rcfile .bwwbashrc

From the bash man page: 从bash手册页:

--rcfile file

Execute commands from file instead of the standard personal initialization file ~/.bashrc if the shell is interactive (see INVOCATION below). 如果外壳是交互式的,请从文件而不是标准的个人初始化文件〜/ .bashrc中执行命令(请参见下面的INVOCATION)。

If you want to replace your current shell (with commands and settings from .bashrc ), you can run 如果要替换当前的shell(使用.bashrc命令和设置),则可以运行

exec bash --rcfile .bwwbashrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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