From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26837 invoked by alias); 28 Apr 2012 21:01:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17030 Received: (qmail 21060 invoked from network); 28 Apr 2012 21:01:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Sat, 28 Apr 2012 16:54:15 -0400 (EDT) From: "Benjamin R. Haskell" To: TJ Luoma cc: zsh-users@zsh.org Subject: Re: do you use separate .zshenv and .zshrc files? In-Reply-To: <4B2741961D3F4053AD4A3F6A195E2371@gmail.com> Message-ID: References: <4B2741961D3F4053AD4A3F6A195E2371@gmail.com> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Sat, 28 Apr 2012, TJ Luoma wrote: > I keep vacillating between wanting to separate my config files into > two separate files or keep them in one. My config currently spans 19 files, so my bias should be apparent. I keep everything in ~/.zsh/, except for machine-specific settings, which I put in ~/.zsh.local/. And ~/.zshenv is a symlink to ~/.zsh/.zshenv, which sets ZDOTDIR to ~/.zsh. My ~/.zsh/.zshrc sources the other files in ~/.zsh/, most of which have some guard at the top (e.g. ~/.zsh/.zsh_screen returns if the `screen` command isn't installed). > If I understand ZSH correctly, I could use one file (.zshenv) and put > the settings which *would* have been in .zshrc into a block like this: > > if [[ -o login ]] You want 'interactive' here, not 'login': if [[ -o interactive ]] > then > # do stuff which would have been in .zshrc here > fi [[ -o login ]] would catch things that would be done in .zprofile and .zlogin, not those that are done in .zshrc. > The reason for doing this is that I tend to forget which file has > whatever thing it is that I want to tweak/edit/change/add, and so I > end up having to open one, search for what I'm looking for, realize > it's in the other file, and then open the other file. > > ISTM that it would be easier to just keep everything in one file and > separate the login stuff using the `if` statement above. As pointed out above .zshenv vs .zshrc isn't a difference of "login" vs. not. It's "interactive" vs. not. Here's the order of the standard four files, and the condition under which they run: .zshenv: (always) .zprofile: [[ -o login ]] .zshrc: [[ -o interactive ]] .zlogin: [[ -o login ]] To disable all of them, there is the 'NO_RCS' option. Personally, I don't use .zprofile or .zlogin, because all of my customization outside of .zshenv is only applicable to interactive shells. > Are there any drawbacks to that method? None that I know of. If that's how you prefer to organize it, it should work fine. -- Best, Ben