Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Change directory on invocation of zsh
- X-seq: zsh-users 8061
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Michael Prokop <zsh@xxxxxxxxxxxxxxxxx>
- Subject: Re: Change directory on invocation of zsh
- Date: Sat, 16 Oct 2004 20:56:30 -0700 (PDT)
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <2004-10-16T23-18-26@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <2004-10-16T23-18-26@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: zsh-users@xxxxxxxxxx
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author