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

Re: zsh startup files



Stefan Monnier wrote:
> >>>>> "Peter" == Peter Stephenson <pws@xxxxxxxxxxxxxxxxx> writes:
> > This makes things rather complicated; there's no fundamental difficulty,
> > but I'd prefer to keep it clean.  The idea is not that you're at war with
> > the sysadmin, who's supposed to make it easy for users to set their own
> > preferences.  But if this is popular enough...
> 
> No.

`No, this idea isn't popular', or `No, I am at war with the sysadmin who
doesn't make it easy'?

Various possibilities are

- set GLOBAL_RCS_FIRST by default in the next version; but whenever we do
something like that, something nasty happens.  True, it shouldn't hurt the
/etc/z* files which have to be able to run with no dot files in between,
but it could have some effect for dot files (can anyone produce an example?)

- make it available in the next version, and announce it may be set by
default in future, so that you should add `unsetopt GLOBAL_RCS_FIRST' to
/etc/zshenv if you really don't want it.

> Actually, now that I think about it, why do we even need all those /etc/z*
> files ?  It seems that all except for either /etc/zprofile or /etc/zshenv
> should be kept empty in all but really unusual circumstances (in which case
> you can still use zshenv for the same purpose).

Potentially, they may be useful, but I certainly agree they're overused and
often abused.  On this system here, we have /etc/zprofile, /etc/zshenv and
/etc/zshrc --- and they're almost identical.

> I guess I could live with just NO_GLOBAL_RCS that I would
> set in my .zshenv although it won't do me any good as a sysadmin.

(Do you mean GLOBAL_RCS_FIRST, or are you proposing a different option for
not running global scripts apart from /etc/zshenv at all?)  If it worked in
.zshenv, it would certainly be made to work in /etc/zshenv: the question
would be whether it should have an effect in .zshenv as well.

> Now, how can I simulate NO_GLOBAL_RCS (I don't want to wait for my
> sysadmins to install a newer zsh version) ?

Again, if you mean, `how do I get all my code to run after the global
scripts have finished', then I can't see any problem with the following,
but I haven't tried it out, so I may have missed something.  I've relied on
the fact that .zshrc is run for any interactive shell (option interactive
is set), and .zprofile and .zlogin for any login shell (option login set),
and that a login shell is always interactive.  That should answer your
other question.

1. Move .zshenv, .zprofile, .zshrc, .zlogin to .real_zshenv,
.real_zprofile, etc, etc.

2a. In .zshenv:

if [[ ! -o interactive ]]; then
  [[ -f ~/.real_zshenv ]] && source ~/.real_zshenv
fi

2b. Delete .zprofile

2c. In .zshrc:

if [[ ! -o login ]]; then
  [[ -f ~/.real_zshrc ]] && source ~/.real_zshrc
fi

2d. In .zlogin:

[[ -f ~/.real_zshenv ]] && source ~/.real_zshenv
[[ -f ~/.real_zprofile ]] && source ~/.real_zprofile
[[ -f ~/.real_zshrc ]] && source ~/.real_zshrc
[[ -f ~/.real_zlogin ]] && source ~/.real_zlogin

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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