4

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?

5

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
  • Wouldn't your first statement be due to using bash as your login shell on the remote machine, as opposed to any inherent difference between bash and zsh? – chepner Aug 7 '14 at 22:15
  • @chepner, I'm saying that would your login shell on the remote machine be bash, you'd be screwed as bash reads ~/.bashrc when invoked over ssh. With zsh (as login shell on the remote machine), you don't have that problem. – Stéphane Chazelas Aug 7 '14 at 22:28
1

You can set up an alternative config file and invoke the shell with that. See https://stackoverflow.com/questions/2727172/how-to-load-different-zshrc-file-via-commandline-option .

  • Yeah, but that's for starting zsh from another shell. You can't do that over SSH, right? As in ssh foo@example.com --alternative-zshrc=whatnot – artfulrobot Jul 4 '14 at 13:34
  • 1
    You can execute commands given as arguments to ssh : ssh user@host zsh --rcs /home/user/zsh.alt – schaiba Jul 4 '14 at 13:39
  • @schaiba, --rcs only enables the rcs option (so reads the .zshrc...) and then that interprets the zsh.alt as a script, so it's not what we want here. – Stéphane Chazelas Jul 4 '14 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.