From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5877 invoked from network); 17 Oct 2004 14:47:53 -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 14:47:53 -0000 Received: (qmail 5417 invoked from network); 17 Oct 2004 14:47:46 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Oct 2004 14:47:46 -0000 Received: (qmail 9556 invoked by alias); 17 Oct 2004 14:47:00 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8062 Received: (qmail 9542 invoked from network); 17 Oct 2004 14:46:59 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Oct 2004 14:46:59 -0000 Received: (qmail 3631 invoked from network); 17 Oct 2004 14:46:00 -0000 Received: from mail.vc-graz.ac.at (HELO proxy.vc-graz.ac.at) (193.171.121.30) by a.mx.sunsite.dk with SMTP; 17 Oct 2004 14:45:59 -0000 Received: from localhost (b-55.vc-graz.ac.at [193.171.241.55]) by proxy.vc-graz.ac.at (8.12.11/8.12.11) with ESMTP id i9HEjw6B015629 for ; Sun, 17 Oct 2004 16:45:58 +0200 (MEST) Date: Sun, 17 Oct 2004 16:45:58 +0200 From: Michael Prokop To: zsh-users@sunsite.dk Subject: Re: Change directory on invocation of zsh Message-ID: <2004-10-17T16-22-44@devnull.michael-prokop.at> Reply-To: Michael Prokop Mail-Followup-To: zsh-users@sunsite.dk References: <2004-10-16T23-18-26@devnull.michael-prokop.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-URL: http://www.michael-prokop.at/ X-Operating-System: Debian GNU/Linux - 2.6.8.1 on a i686 X-Registered-Linux-User: 224337 X-Crypto: GnuPG/1.2.3 http://www.gnupg.org X-GPG-Key-ID: 0x37E272E8 X-GPG-Key: http://www.michael-prokop.at/gpg X-GPG-Fingerprint: 04AE E62C 9502 CD34 A7DA 857B D8DF 53FB 37E2 72E8 User-Agent: Mutt/1.5.6i 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 Bart, thanks a lot for your fast reply! * Bart Schaefer [20041017 10:13]: > 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. Upps. Corrected, thanks. > > | 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 Thanks. It seems to work on the "last tty", but on the other ones I'm getting: /etc/zsh/zshrc:cd:22: no such file or directory: /home/LOGIN $ echo $LOGNAME LOGIN $ whoami grml $ id -un grml I can't find the reason for this behaviour (inittab entries are the same and behaviour seems to change when booting system serveral times), but using `id -un` instead of $LOGNAME seems to fix it. > > 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? Ah, ok - I see what you mean. Yes, seems to be related. > > 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 Oh, my thinking was too complicated. :) Thanks Bart, works like a charme! thx && regards, (-: Michael