如何在 MacOS Catalina(Zsh)上编辑 $PATH?

如何在 MacOS Catalina(Zsh)上编辑 $PATH?

我打开终端并使用echo $PATH

我回复说:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin/

我很困惑,因为我的、、、、.zshrc和全部里面都没有任何东西.zsh.bash_profile.bashrc.profile

我没有所有这些,但我启用了隐藏文件夹和文件来查看是否有。

我查看了默认系统的路径。/etc/path想看看那里是否有东西,但它只是默认的。我唯一担心的是,那里的文件与远程数据包有关rvictl

答案1

在 macOS 上,您的信息$path已预先填充到/etc/zprofile

% < /etc/zprofile
# System-wide profile for interactive zsh(1) login shells.

# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
# and zshoptions(1) for more details.

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

% man path_helper

path_helper(8)            BSD System Manager's Manual           path_helper(8)

NAME
     path_helper -- helper for constructing PATH environment variable

SYNOPSIS
     path_helper [-c | -s]

DESCRIPTION
     The path_helper utility reads the contents of the files in the directories /etc/paths.d and /etc/manpaths.d and appends their contents to the PATH and MANPATH environment vari-
     ables respectively.  (The MANPATH environment variable will not be modified unless it is already set in the environment.)

     Files in these directories should contain one path element per line.

     Prior to reading these directories, default PATH and MANPATH values are obtained from the files /etc/paths and /etc/manpaths respectively.

     Options:

     -c      Generate C-shell commands on stdout.  This is the default if SHELL ends with "csh".

     -s      Generate Bourne shell commands on stdout.  This is the default if SHELL does not end with "csh".

NOTE
     The path_helper utility should not be invoked directly.  It is intended only for use by the shell profile.

Mac OS X                        March 15, 2007                        Mac OS X

相关内容