V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
gIrl1990
V2EX  ›  问与答

MacOS: $PATH 里有个目录不知是如何添加进去的。Wireshark.app

  •  
  •   gIrl1990 · 2019-09-06 15:51:47 +08:00 · 875 次点击
    这是一个创建于 1695 天前的主题,其中的信息可能已经有所发展或是发生改变。
    fish > set -S PATH
    
    $PATH: not set in local scope
    
    $PATH: set in global scope, exported, with 10 elements
    
    $PATH[1]: length=14 value=|/usr/local/bin|
    
    $PATH[2]: length=8 value=|/usr/bin|
    
    $PATH[3]: length=4 value=|/bin|
    
    $PATH[4]: length=9 value=|/usr/sbin|
    
    $PATH[5]: length=5 value=|/sbin|
    
    $PATH[6]: length=42 value=|/Applications/Wireshark.app/Contents/MacOS|
    
    $PATH[7]: length=75 value=|/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources|
    
    隐藏 8 9 10
    
    $PATH: not set in universal scope
    

    几个已知的 Bash Startup Files 里找过了,木有~

    1 条回复    2020-12-03 10:41:08 +08:00
    magicfan
        1
    magicfan  
       2020-12-03 10:41:08 +08:00
    [How to use /etc/paths.d to add executable files to my path?]( https://apple.stackexchange.com/questions/128897/how-to-use-etc-paths-d-to-add-executable-files-to-my-path)
    [Use /etc/paths or /etc/paths.d to add items to the PATH in macOS Sierra?]( https://unix.stackexchange.com/questions/342574/use-etc-paths-or-etc-paths-d-to-add-items-to-the-path-in-macos-sierra)

    The paths in `/etc/paths.d/` are added to the path by `/usr/libexec/path_helper`, which is run from `/etc/profile`, `/etc/zprofile`, and `/etc/csh.login`.

    可执行 `man path_helper` 查看相关说明。

    以下为 macOS ZSH 下的 PATH 变量:

    ```
    $ echo $PATH | awk 'BEGIN{RS=":"} {print}'
    # 省略在 ~/.zshrc 中追加在 PATH 前面的配置
    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /opt/X11/bin
    /Library/Apple/usr/bin
    /Applications/Wireshark.app/Contents/MacOS
    # 省略在 ~/.zshrc 中追加在 PATH 后面的配置
    ```

    前面 5 个为 `/etc/paths` 中预定义的路径;后面 3 个为 `/etc/paths.d` 中配置的环境变量:

    ```
    $ ls -1 /etc/paths.d/
    100-rvictl
    40-XQuartz
    Wireshark
    ```

    每个文件里面包含一行可执行路径,被 `/etc/profile` 或 `/etc/zprofile` 执行 path_helper 加载到 PATH 环境变量中:

    ```
    $ cat /etc/paths.d/40-XQuartz
    /opt/X11/bin
    $ cat /etc/paths.d/100-rvictl
    /Library/Apple/usr/bin
    $ cat /etc/paths.d/Wireshark
    /Applications/Wireshark.app/Contents/MacOS
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2747 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 10:21 · PVG 18:21 · LAX 03:21 · JFK 06:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.