Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Change directory on invocation of zsh
- X-seq: zsh-users 8062
- From: Michael Prokop <news@xxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Change directory on invocation of zsh
- Date: Sun, 17 Oct 2004 16:45:58 +0200
- In-reply-to: <Pine.LNX.4.61.0410161942220.8058@xxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <2004-10-16T23-18-26@xxxxxxxxxxxxxxxxxxxxxxxxx> <Pine.LNX.4.61.0410161942220.8058@xxxxxxxxxxxxxxxxxx>
- Reply-to: Michael Prokop <zsh@xxxxxxxxxxxxxxxxx>
Bart, thanks a lot for your fast reply!
* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> [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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author