从手册页:
STARTUP/SHUTDOWN FILES
Commands are first read from /etc/zshenv; this cannot be overridden. Subsequent be‐
haviour is modified by the RCS and GLOBAL_RCS options; the former affects all startup
files, while the second only affects global startup files (those shown here with an
path starting with a /). If one of the options is unset at any point, any subsequent
startup file(s) of the corresponding type will not be read. It is also possible for
a file in $ZDOTDIR to re-enable GLOBAL_RCS. Both RCS and GLOBAL_RCS are set by
default.
Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, com‐
mands are read from /etc/zprofile and then $ZDOTDIR/.zprofile. Then, if the shell is
interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if
the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.
When a login shell exits, the files $ZDOTDIR/.zlogout and then /etc/zlogout are read.
This happens with either an explicit exit via the exit or logout commands, or an
implicit exit by reading end-of-file from the terminal. However, if the shell termi‐
nates due to exec'ing another process, the logout files are not read. These are also
affected by the RCS and GLOBAL_RCS options. Note also that the RCS option affects
the saving of history files, i.e. if RCS is unset when the shell exits, no history
file will be saved.
If ZDOTDIR is unset, HOME is used instead. Files listed above as being in /etc may
be in another directory, depending on the installation.
As /etc/zshenv is run for all instances of zsh, it is important that it be kept as
small as possible. In particular, it is a good idea to put code that does not need
to be run for every single shell behind a test of the form `if [[ -o rcs ]]; then
...' so that it will not be executed when zsh is invoked with the `-f' option.
因此,您应该能够将环境变量ZDOTDIR
设置为新目录,以使zsh查找不同的点文件集。
由于该男子页显示,RCS
并GLOBAL_RCS
没有路径RC文件,您正在尝试使用它们,而是选项,你可以启用或禁用。因此,例如,该标志--rcs
将启用该RCS
选项,从而导致zsh从rc文件读取。您可以使用以下命令行标志对zsh启用或禁用RCS
或GLOBAL_RCS
:
--globalrcs
--rcs
-d equivalent to --no-globalrcs
-f equivalent to --no-rcs
要回答您的其他问题:
是否有可能启动zsh,运行“ source / path / to / file”,然后停留在同一zsh会话中?
是的,按照上述说明,这非常容易。只需运行zsh -d -f
然后source /path/to/zshrc
。