在ZSH中将新条目添加到PATH变量中 [英] Adding a new entry to the PATH variable in ZSH
问题描述
我正在使用zsh,并且正在尝试向PATH
变量添加新条目(/home/david/pear/bin
),但是我不知道怎么做.
I'm using zsh and I'm trying to add a new entry (/home/david/pear/bin
) to the PATH
variable but I don't know how.
最让我困惑的是,没有一个人
对我的~/.zshrc
文件中的PATH
变量的引用,但执行echo $PATH
会返回:
The thing that confuses me the most is that there's not a single
reference to a PATH
variable in my ~/.zshrc
file, but doing echo $PATH
returns:
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
因此在某处设置了PATH
变量.
So a PATH
variable is being set somewhere.
推荐答案
此处:
export PATH=/home/david/pear/bin:$PATH
编辑:确实可以,但是下面的 ony的答案更好,因为它需要ZSH提供的结构化接口的优点是提供了像$PATH
这样的变量.这种方法是bash
的标准方法,但是据我所知,当ZSH提供更好的替代方法时,没有理由使用它.
EDIT: This does work, but ony's answer below is better, as it takes advantage of the structured interface ZSH provides for variables like $PATH
. This approach is standard for bash
, but as far as I know, there is no reason to use it when ZSH provides better alternatives.
这篇关于在ZSH中将新条目添加到PATH变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!