在ZSH中将新条目添加到PATH变量中 [英] Adding a new entry to the PATH variable in ZSH

查看:352
本文介绍了在ZSH中将新条目添加到PATH变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆