From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25591 invoked from network); 17 Oct 2004 03:58:30 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 Oct 2004 03:58:30 -0000 Received: (qmail 45878 invoked from network); 17 Oct 2004 03:58:24 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Oct 2004 03:58:24 -0000 Received: (qmail 20513 invoked by alias); 17 Oct 2004 03:57:39 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8061 Received: (qmail 20499 invoked from network); 17 Oct 2004 03:57:38 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Oct 2004 03:57:38 -0000 Received: (qmail 44586 invoked from network); 17 Oct 2004 03:56:39 -0000 Received: from moonbase.zanshin.com (64.84.47.139) by a.mx.sunsite.dk with SMTP; 17 Oct 2004 03:56:36 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.13.1/8.13.1) with ESMTP id i9H3uUAm025269; Sat, 16 Oct 2004 20:56:30 -0700 Date: Sat, 16 Oct 2004 20:56:30 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: Michael Prokop cc: zsh-users@sunsite.dk Subject: Re: Change directory on invocation of zsh In-Reply-To: <2004-10-16T23-18-26@devnull.michael-prokop.at> Message-ID: References: <2004-10-16T23-18-26@devnull.michael-prokop.at> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 On Sat, 16 Oct 2004, Michael Prokop wrote: > little wrapper in my zsh config: > > ,---- [ /etc/zsh/zshrc ] Why zshrc rather than zshenv? The wrong ~/.zshenv will be loaded if $HOME is not set correctly before the end of the global zshenv. > | if [[ -z "$HOME" || "$HOME" == "/" ]] ; then > | if [[ `id -un` == "root" ]] ; then > | export HOME=/root > | else > | export HOME=/home/`id -un` > | fi > | fi > `---- Using `id -un` there, particularly twice, should not be necessary. E.g., if (( EUID == 0 )); then export HOME=/root else export HOME=/home/$LOGNAME fi > Of course running 'cd' or 'cd $HOME' or 'cd ~' changes into my > homedirectory. But I'd like to change path already on login. So whether HOME is set correctly (before executing the above snippet) has nothing to do with whether the current directory is "/" ? I would expect the two conditions to be related, e.g., if [[ -z "$HOME" || "$HOME" == "/" ]] ; then # ... export $HOME correctly, then ... cd fi Or is there some reason you don't want to have the "cd" in the global config? > Doing something like '[ $SECONDS == "0" ] && cd $HOME' is a > workaround but changes the working directory to $HOME any time I'm > starting a new zsh. Am I on the wrong way? How about something like if [[ -z "$ALREADY_DID_CD_HOME" ]]; then export ALREADY_DID_CD_HOME=$HOME cd fi