On a remote machine I changed my zsh settings and it is now broken,
for every keypress it says: "url-quote-magic:1: url-quote-magic: function definition file not found "

I don't have another account on that machine, What can I do to disable the faulty .zshrc so that I can use my shell again and fix it.

6 Answers 6


You can run a command on the remote server without logging in like this:



ssh -lsomeuser someserver 'mv .zshrc .zshrc.bak'

The command given as last argument to ssh will be executed by a non-interactive shell and commands from .zshrc are only executed by interactive shells (see zsh manpage, section on startup and shutdown files).

  • Yes that works fine! Thanks. Although I use a "key" to login and for me it looks like: ssh servername 'mv .zshrc .zshrc.broken'
    – Ali
    Feb 1, 2012 at 19:12

I could also sftp to the server and overwrite the .zshrc with an empty file or with one that works!


Here, it's easy because the file you've messed up is only used by interactive logins. If you'd messed up ~/.zshenv, or if your login shell was bash and you'd messed up ~/.bashrc (weirdly, bash reads ~/.bashrc if it's a non-interactive login shell and its parent is rshd or sshd), none of the methods that rely on executing a command non-interactively would work.

SSH insists on running a shell. If you have no other way to log in (via another account or via a method other than ssh), then your only recourse is to press Ctrl+C really fast after you're authenticated and before the shell reaches the problematic line. In practice, this can often be done manually; it may help to arrange for the machine to be heavily loaded (CPU or disk). If you have trouble pressing the keys at the right time, try using expect.


This issue just happened to me (d'oh!), and I fired up my gui text editor, TextWrangler, to connect to my remote server, then via TextWrangler > Open from FTP/SFTP server, went to .zshrc on my remote server, fixed the file (edited a bad PATH line), saved the fixed file, restarted my terminal, and the problem was resolved. Hello again, Zsh!

BBEdit is another free editor (same company, Bare Bones Software, Inc.) that allows access to files on remote servers (TextWrangler is still available, but has been sunsetted).


I could have changed my shell to bash using:

ssh -luser server 'chsh -s /bin/bash'  

assuming bash is available on the server and it works for me.


I tried to do a remote edit with vim:

vim sftp://user@server/.zshrc

which didn't work. Although :Nread sftp://server/.zshrc could load the broken .zshrc file and :Nwrite could write it back (I have my public key on the server and ssh without a password).

Still more solutions are very welcome.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .