4

When starting my shell with e.g. exec zsh from the command line, how can I have it not parse any /etc/ files?

I read in the zsh guide that when a user starts a zsh shell, it processes the following init files in order:

# Every shell. Always
/etc/zshenv

# Every shell. Avoidable if passing flag -f to zsh
~/zshenv

# If it's a login shell.
/etc/zprofile
~/zprofile

# If it is an interactive shell
/etc/zshrc
~/zshrc

# If it is a login shell
/etc/zlogin
~/zlogin

When starting zsh, I would like to skip processing all the /etc/* files (except /etc/zshenv which I assume I can't skip as a non-root user?), and only parse my own init files in my home directory.

How can I do this when I invoke exec zsh from the command line?

| improve this question | | | | |
7

Unset the GLOBAL_RCS option. To do this, add unsetopt GLOBAL_RCS to /etc/zshenv or $ZDOTDIR/.zshenv or run zsh -o NO_GLOBAL_RCS. Note that if $ZDOTDIR is unset, $HOME is used instead.

When GLOBAL_RCS is unset, /etc/zprofile, /etc/zshrc, /etc/zlogin and /etc/zlogout will not be sourced.

| improve this answer | | | | |
  • Thanks. I do not have admin rights to edit /etc/zshenv. I guess I can add this to ~/zshenv instead? – Amelio Vazquez-Reina Apr 15 '13 at 23:24
  • 1
    That will work. You personal zshenv file is sourced right after /etc/zshenv, before the other config files are sourced. I have edited my answer to include that. – user26112 Apr 15 '13 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.