zsh - 找不到书面脚本的命令

zsh - command not found for written script

我正在使用 mac 并且我有一个脚本文件 print_hello:

#!/bin/bash
echo hello

如果我直接从目录 运行 使用 ./print_hello 命令和 zsh 终端,它将正确打印 hello。我想将它添加为全局命令,因此在终端中写入 print_hello 应该会打印出我 "hello"。但我得到的是:

zsh: command not found: print_hello

路径是正确的(我在.zshrc中编辑了它)。该文件具有适当的权限(我使用 chmod 755 print_hello):

➜ ~ echo $PATH
/Users/mateusz/bin:/usr/local/bin:/Users/mateusz/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/GE/bin:~/scripts

并且 print_hello 文件位于 ~/scripts

我可以 运行 脚本的唯一方法是直接从其目录中获取。我应该怎么办?我在 .zshrc 中添加了一些别名并且它们正在工作,那么为什么可执行脚本不起作用?

这很奇怪,但对我有帮助的是替换

~/scripts

$HOME/scripts

在 .zhrc 文件中