简体   繁体   English

如何协调 bash 配置文件与 zsh

[英]How to coordinate bash profile with zsh

I recently switched my shell from bash to zsh.我最近将我的 shell 从 bash 切换到 zsh。 I had set up Anaconda via bash, but now that I'm running zsh as my default shell, I can't find conda or, more importantly, Jupyter.我已经通过 bash 设置了 Anaconda,但现在我正在运行 zsh 作为我的默认 shell,我找不到 conda,或者更重要的是,找不到 Jupyter。 I've figured that to get access to Jupyter I can use exec bash -l , but that seems pointlessly temporary.我认为要访问 Jupyter,我可以使用exec bash -l ,但这似乎是临时性的。 I would rather access Jupyter locally from zsh.我宁愿从 zsh 在本地访问 Jupyter。 Is there some way to link zsh back to the bash configs?有什么方法可以将 zsh 链接回 bash 配置吗?

Since zsh can interpret most of bash, you can have it include the bash init files in its corresponding init files.由于 zsh 可以解释大部分 bash,因此您可以让它在其相应的 init 文件中包含 bash init 文件。

To do this, add eg the line source ~/.bashrc in ~/.zshrc为此,请在~/.zshrc中添加例如 line source ~/.bashrc

Each shell has many different config files and they don't correspond 1:1, so look through and see which ones you want to link.每个 shell 都有许多不同的配置文件,它们不是 1:1 对应的,因此请查看您要链接的文件。 For example, zsh login shells reads both .zlogin and .zprofile , while bash login shells read only the first available of .bash_profile , .bash_login and .profile例如,zsh 登录 shell 读取.zlogin.zprofile ,而 bash 登录 shell 仅读取.bash_profile.bash_login.profile的第一个可用

I was having an issue with mysql: command not found after I had set the PATH correctly in .bash_profile .我在 mysql 中遇到问题:在.bash_profile中正确设置 PATH 后mysql: command not found

What worked great for me was the following:对我有用的是以下内容:

  1. Add source ~/.bash_profile to the first line of ~/.zprofilesource ~/.bash_profile添加到~/.zprofile的第一行
  2. Restart Terminal重启终端

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM