bash 如何通过命令行选项加载不同的 zshrc 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2727172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 22:01:24  来源:igfitidea点击:

How to load different zshrc file via commandline option?

bashzsh

提问by user327523

I used to do this with bash...

我曾经用 bash 这样做过......

/bin/bash --rcfile /home/sindhu/bin/misc_scripts/shellrc/.bashrc_1

how can I accomplish the same with zsh?

我怎样才能用 zsh 完成同样的事情?

Thank you.

谢谢你。

采纳答案by Paused until further notice.

You can approximate that feature by using the ZDOTDIRvariable.

您可以使用ZDOTDIR变量来近似该特征。

In a directory perhaps like this:

在可能像这样的目录中:

mkdir /home/sindhu/bin/misc_scripts/shellrc/.zshrc_1

create a file called .zshrccontaining your alternative startup script. Then you can start zsh like this:

创建一个名为的文件,.zshrc其中包含您的备用启动脚本。然后你可以像这样启动 zsh:

ZDOTDIR=/home/sindhu/bin/misc_scripts/shellrc/.zshrc_1 zsh

回答by jkramer

Write a small wrapper script:

编写一个小包装脚本:

source 
zsh -f -d

The first line sources your alternative RC file. The second starts a new Z shell without sourcing any other RC files. See zshoptions(1) for the options -d and -f (GLOBAL_RCS, RCS).

第一行来源您的替代 RC 文件。第二个启动一个新的 Z shell,而不使用任何其他 RC 文件。有关选项 -d 和 -f(GLOBAL_RCS、RCS),请参阅 zshoptions(1)。