.zshenv 或 .zshrc 中的 PATH 变量 [英] PATH variable in .zshenv or .zshrc
问题描述
我的设置是 arch linux 中的 zsh 5.0.5
My setup is zsh 5.0.5 in arch linux
我在 .zshenv 中设置了如下的 PATH 变量
I have set the PATH variable as below in .zshenv
typeset -U path
path=(~/bin $path)
DW=$HOME/Downloads
但是没有用.打印 $PATH 仅显示
but it didn't work. print $PATH shows only
/usr/local/bin:/usr/bin:/usr/bin/vendor_perl:/usr/bin/core_perl
.zshenv 被读取,因为我可以看到 DW 变量已设置.只有 PATH 变量没有设置.我不明白的是,在将 .zshenv 重命名为 .zshrc 后,PATH 变量按预期工作.
.zshenv was read, because I could see DW variable is set. Only PATH variable isn't set. And what I don't understand is, after rename the .zshenv to .zshrc, PATH variable just works as intended.
在 .zshenv 中需要任何特殊处理设置环境变量吗?
Need any special treatment setting environment variables in .zshenv?
推荐答案
我自己刚遇到这个问题,真正的答案是 Arch 源代码上的 Zsh /etc/profile
– 覆盖和导出PATH
– after 获得 ~/.zshenv
.
I just encountered this problem myself, and the real answer is that Zsh on Arch sources /etc/profile
– which overwrites and exports PATH
– after having sourced ~/.zshenv
.
参见:https://wiki.archlinux.org/index.php/Zsh#Configuration_files
这篇关于.zshenv 或 .zshrc 中的 PATH 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!