我在 fish
shell 中的 cd
基本行为遇到问题。
cd
到相对目录
我愿意使用不带 ./
的相对路径来更改目录。该目录存在:
❯ ls
addons/ custom-addons/ docker-compose.yml
该目录是自动完成的,但我无法更改它:
❯ cd addons/
cd: The directory “addons/” does not exist
CDPATH
set -gx CDPATH $CDPATH $HOME/projects
最佳答案
如文档部分所述Special Variables :
CDPATH
, an array of directories in which to search for the new directory for the cd builtin. By default, the fish configuration definesCDPATH
to be a universal variable with the values.
and~
.
诊断
我在忽略 .
和 ~
值时覆盖了默认值。
解决方案
将它们添加回来解决了问题,在 ~/.config/fish/config.fish
中:
set -gx CDPATH $CDPATH . ~ $HOME/projects
然后用以下命令重新加载fish
:
exec fish
关于shell - Fish shell cd使用相对路径返回: The directory “whatever” does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35554887/