解决:zsh环境下,/etc/profile.d文件夹下的脚本不执行

1 问题描述
安装了zsh后,当我按照conda的提示将conda.sh添加到/etc/profile.d文件夹后并没有生效。
2 解决过程
查看zsh官方文档,大致了解了/etc/zsh目录下的各个文件作用。
在文档中看到这一行字。
Warning: Do not remove the default one line in /etc/zsh/zprofile, otherwise it will break the integrity of other packages which provide some scripts in /etc/profile.d/.

也就是说,/etc/zsh/zprofile文件里面有一行默认的文字,与/etc/profile.d文件夹下的脚本有关。然而当我们打开zprofile文件只看到有一堆注释,所以显然缺少了这行默认文字。
至此可以推测/etc/zsh/zprofile文件对应的是/etc/profile文件,我们把/etc/profile文件中用来执行/etc/profile.d/下脚本的命令复制到zprofile中,问题解决~~
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
————————————————
版权声明:本文为CSDN博主「TKONIY」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43558951/article/details/104346652


已发布

分类

,

来自

标签:

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注