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

时间:2018-06-27 12:34:32

标签: bash macos zsh iterm2 zshrc

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

#!/bin/bash
echo hello

,如果我使用./print_hello命令和zsh终端直接从目录运行它,它将正确打印问候。我想将其添加为全局命令,因此在终端中写入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中添加了一些别名,这些别名可以工作,那么为什么可执行脚本不能工作?

1 个答案:

答案 0 :(得分:2)

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

~/scripts

使用

$HOME/scripts

.zhrc文件中的