用鱼壳修改 PATH [英] Modifying PATH with fish shell

查看:20
本文介绍了用鱼壳修改 PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在玩 fish shell,但我很难理解如何使用PATH 变量已设置.对于它的价值,我也在使用 oh-my-fish.

I'm currently playing around with the fish shell and I'm having some trouble wrapping my head around how the PATH variable is set. For what it's worth, I'm also using oh-my-fish.

如果我回显我当前的路径,我会得到:

If I echo my current path I get:

➜ fish echo $PATH
/usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/texbin /Users/myname/.opam/system/bin

查看 ~/.config/fish/config.fish 我看到以下行

set PATH /usr/local/bin $PATH /Users/myname/.opam/system/bin

我的问题是(这个措辞可能反映了我对该主题缺乏了解):在处理 config.fish 之前,PATH 变量集在哪里?即: /usr/local/bin/Users/myname/.opam/system/bin 之间的所有路径都来自哪里?

My question is (and this phrasing will probably reflect my lack of knowledge on the subject): prior to config.fish being processed, where is the PATH variable set? ie: where do all of the paths between /usr/local/bin and /Users/myname/.opam/system/bin come from?

推荐答案

中所述官方鱼教程,可以修改$fish_user_paths通用变量.

As stated in the official fish tutorial, you can modify the $fish_user_paths universal variable.

从命令行运行一次:

set -U fish_user_paths /usr/local/bin $fish_user_paths

这会将 /usr/local/bin 永久添加到您的路径中,并且也会影响当前会话和所有未来实例,因为 -U 参数将使变量 通用.

This will prepend /usr/local/bin permanently to your path, and will affect the current session and all future instances too because the -U argument will make the variable universal.

来自 fish 文档:

...(注意:您不应该将此行添加到 config.fish.如果这样做,每次运行 fish 时变量都会变长!)

... (Note: you should NOT add this line to config.fish. If you do, the variable will get longer each time you run fish!)

fish_user_paths,附加到 PATH 的目录列表.这可以是一个通用变量.

fish_user_paths, a list of directories that are prepended to PATH. This can be a universal variable.

这篇关于用鱼壳修改 PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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