有没有办法在登录时绕过 .zshrc?

art*_*bot 4 zsh

我很享受学习 ZSH,但有一件事困扰着我。如果我在我的 .zshrc 中放了一些使 shell 无用的东西(我正在玩一些影响键盘解释方式的东西),那么我最终可能无法修复它,除非我可以在登录时绕过我的 zshrc。

有办法吗?

Sté*_*las 5

与 相反bash,在 上运行命令时zsh不读取。所以如果你搞砸了你的,你总是可以这样做:.zshrcsshzshrc

ssh machine mv .zshrc .zshrc.disabled
Run Code Online (Sandbox Code Playgroud)

从另一台机器上把你放在一边.zshrc

如果你想测试一个 zshrc,你可以把它放在另一个目录中并运行zsh

ZDOTDIR=/that/dir zsh
Run Code Online (Sandbox Code Playgroud)

到与运行的zsh .zshrc(或.zshenv.zprofile/ .zlogin/.zlogoutzsh -l)。

您还可以通过 ssh 使用该 ZDOTDIR 登录:

ssh -t machine ZDOTDIR=/that/dir zsh -l
Run Code Online (Sandbox Code Playgroud)