magicfan's recent timeline updates
magicfan

magicfan

V2EX member #64010, joined on 2014-06-01 12:13:16 +08:00
magicfan's recent replies
[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
```
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1281 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 16:52 · PVG 00:52 · LAX 09:52 · JFK 12:52
♥ Do have faith in what you're doing.