Not sure why you'd want to do that, but you can do:
exec env -i /home/path/to/my/zsh
Probably many things won't work properly as you'll be missing some essential environment variables like $PATH
, $HOME
or $TERM
.
If you want to whitelist a few variables and remove the rest:
exec env -i HOME="$HOME" TERM="$TERM" /home/path/to/my/zsh
If you want to restore the environment at the time tcsh
was started, you could insert this to the very beginning of ~/.tcshrc
:
sh -c 'export -p' > ~/.initial-env
And then do something like:
exec env -i sh -c ". $HOME/.initial-env; exec /path/to/zsh"
That is save the environment when tcsh
starts and restore it when you execute zsh.
If what you want is change your shell to zsh
while you don't have to possibility to do a chsh
(or zsh
is not installed or the one installed is 20 years old), (brings back memory from over 15 years ago (gosh!) when I was in the exact same situation (though with csh
instead of tcsh
)), you can replace the content of your ~/.login
with:
setenv SHELL /path/to/zsh
exec $SHELL -l
And remove your .tcshrc
Setting $SHELL
specifies your shell preference (that is what applications like xterm
or vi
... will start when they need to start a shell for you).
Putting it in your ~/.login
should ensure it's only done once. Hopefully, no more tcsh
would be started later on during your login session since you've changed $SHELL
. It shouldn't matter whether you put your environment variable definitions in ~/.login
or ~/.zprofile
or ~/.profile
. It's up to you.
Test with tcsh -l
before logging out.
.zshrc
, since Zsh is the only interactive shell that I use. Does my approach to this problem make sense? – Amelio Vazquez-Reina Mar 11 '13 at 21:26exec /home/path/to/my/zsh
or ratherexec /home/path/to/my/zsh -l
to make zsh load~/.zprofile
. If there's some environment variable you don't want, unset it in your.zprofile
. – Gilles 'SO- stop being evil' Mar 11 '13 at 22:48