Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: do you use separate .zshenv and .zshrc files?

On Apr 28,  3:07pm, TJ Luoma wrote:
} ISTM that it would be easier to just keep everything in one file and
} separate the login stuff using the `if` statement above.
} Are there any drawbacks to that method?

In addition to the items other have mentioned ...

If you have a lot of configuration it may take somewhat longer to parse
and execute the one big file when all that's going to happen is that a
large part of it will be skipped.  Remember that an "if" is a compound
statement which has to all be read into memory to be sure it parses
correctly before any of it can be executed (or discarded, if the
condition is false).  So a giant "if [[ -o interactive ]]; ..." may
needlessly consume memory and time.

I have a multi-file configuration which consists of

$HOME/.zshenv which sets ZDOTDIR to point at

a directory checked out of a source code repository which contains the
actual initialization files.

Within that directory are subdirectories for each host or host type
for which there is a customized config.  I symlink one of those to
"local" and then in (for example) $ZDOTDIR/.zshrc I will have

	desire $ZDOTDIR/local/termsetup

where "desire" is a function defined early like

	desire() { [[ -O $1 ]] && source $1 }

so I don't have to care if a particular local configuration is missing.

Messages sorted by: Reverse Date, Date, Thread, Author