Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh - command not found for written script

I am using mac and I have a script file print_hello:

#!/bin/bash
echo hello

and if I run it directly from directory with ./print_hello command and zsh terminal it will properly print hello. I would like to add it as a global command, so then writing print_hello in terminal should print me "hello". but the thing I am getting is:

zsh: command not found: print_hello

The path is right ( I edited it in .zshrc). The file has the proper permissions (I used 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

and the print_hello file is in ~/scripts

The only way I can run the script is directly from its directory. What should I do? I added some aliases in .zshrc and they are working, so why are executable scripts are not working?

like image 284
Mateusz Avatar asked Jun 27 '18 12:06

Mateusz


1 Answers

It is strange, but the thing that helped me was replacing

~/scripts

with

$HOME/scripts

in .zhrc file

like image 69
Mateusz Avatar answered Oct 01 '22 13:10

Mateusz