Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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
share|improve this answer
    
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 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 at 22:28

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

share|improve this answer
    
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 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 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 at 14:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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