5

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?

1 Answer 1

10

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.

2
  • Thanks. I do not have admin rights to edit /etc/zshenv. I guess I can add this to ~/zshenv instead? Commented Apr 15, 2013 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. Commented Apr 15, 2013 at 23:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.