zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Michael Prokop <zsh@michael-prokop.at>
Cc: zsh-users@sunsite.dk
Subject: Re: Change directory on invocation of zsh
Date: Sat, 16 Oct 2004 20:56:30 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0410161942220.8058@toltec.zanshin.com> (raw)
In-Reply-To: <2004-10-16T23-18-26@devnull.michael-prokop.at>

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


  reply	other threads:[~2004-10-17  3:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-16 21:39 Michael Prokop
2004-10-17  3:56 ` Bart Schaefer [this message]
2004-10-17 14:45   ` Michael Prokop
2004-10-17 16:26     ` Bart Schaefer
2004-10-17 18:55       ` Michael Prokop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0410161942220.8058@toltec.zanshin.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    --cc=zsh@michael-prokop.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).