Way to bypass .zshrc on login

zsh

I'm enjoying learning ZSH, but one thing's bugging me. If I put something in my .zshrc that renders the shell useless (I'm playing with something that affects the way the keyboard is interpreted), then I could end up not being able to fix it unless I can bypass my zshrc on login.

Is there a way?

Best Answer

Contrary to bash, zsh doesn't read .zshrc when running commands over ssh. So if you mess up your zshrc, you can always do:

ssh machine mv .zshrc .zshrc.disabled

from another machine to put your .zshrc out of the way.

If you want to test a zshrc, you can put it in another directory and run zsh as:

ZDOTDIR=/that/dir zsh

to run zsh with that .zshrc (or .zshenv or .zprofile/.zlogin/.zlogout with zsh -l).

You can also login with that ZDOTDIR over ssh with:

ssh -t machine ZDOTDIR=/that/dir zsh -l