如何设置 zsh 使用物理路径?

如何设置 zsh 使用物理路径?

在 bash 中,我可以放入set -P我的.bashrc, 并使用绝对路径。也就是说,如果我通过符号链接更改到目录,然后使用cd ..,它会将我带到该目录的规范父目录,而不是包含符号链接的目录。

如何配置 zsh 始终使用绝对路径?

答案1

zshoptions(1)

   CHASE_LINKS (-w)
          Resolve symbolic links to their true values when changing direc-
          tory.  This also has the effect of CHASE_DOTS, i.e. a `..'  path
          segment  will  be  treated  as referring to the physical parent,
          even if the preceding path segment is a symbolic link.

所以你会setopt CHASE_LINKS在你的某个地方.zshrc。还有一些标志cd会改变cd行为方式。

          If  the -s option is specified, cd refuses to change the current
          directory if the given pathname contains symlinks.   If  the  -P
          option is given or the CHASE_LINKS option is set, symbolic links
          are resolved to their true values.  If the -L  option  is  given
          symbolic  links are retained in the directory (and not resolved)
          regardless of the state of the CHASE_LINKS option.

相关内容