shell - Fish shell cd使用相对路径返回: The directory “whatever” does not exist

标签 shell cd fish

我在 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 defines CDPATH 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/

相关文章:

Bash:递归复制命名文件,保留文件夹结构

python - 试图让 Anaconda3 在 Mac 上运行

linux - 重命名每个组中的最新文件

构建过程成功后,来自 xxx.xxx.xxx.xxx 的 Jenkins JNLP4-connect 连接失败

c# - 如何使用 C# 或 Java 创建音频 CD

fish - 在 fish shell 中将命令拆分为多行

shell - 如何使用fish_prompt_pwd_dir_length 在提示中更改fish pwd 长度?

bash - 我如何才能使读取在 Shell 脚本中不显示其值(value)?

string - fish shell : validate if string contains substring