in my $PATH I have folder ~/.zsh/bin which I use for small scripts and custom built executable binaries, for example I added a recently compiled tool I made called wercker_build_status to the folder. Yet when I type in the command line wercker_build_status it can't find it, I have to type the full path to the file, ~/.zsh/bin/wercker_build_status.

That's not to say nothing in the folder doesn't work, a script I have called wifi_status is in there and typing that into the command line returns the wifi status as expected.

Why is it even though it's in my $PATH I can't just use a file I add to the folder ~/.zsh/bin?

  • I suppose it works if you open a new terminal window (or any way to spawn a new shell)? Apr 3 '18 at 9:08
  • What is your PATH? Is the tool executable? Is zsh OK with having tilde in PATH instead of $HOME?
    – Kusalananda
    Apr 3 '18 at 9:09
  • @UlrichSchwarz it does not why does my $PATH matter when I explicitly stated that the folder is in the path? and yes it is executable and so far I've never had a problem with ZSH and having a tild in the PATH.
    – Thermatix
    Apr 3 '18 at 9:25
  • OK, so it's probably not a caching issue. (IIRC, zsh will cache the names for tab completion, I'm not sure if it does the same for searching the path.) Apr 3 '18 at 10:18
  • M. Schwarz is thinking of unix.stackexchange.com/questions/408859 , unix.stackexchange.com/questions/82991 , and many others in the same vein.
    – JdeBP
    Apr 3 '18 at 17:34

Use $HOME in your path rather than tilde (~), especially if you enclose the new PATH in double quotes. The tilde is not expanded when it occurs in quotes.


$ mkdir "$HOME/t"

$ cat >"$HOME/t/foo" <<END
echo "hello"

$ chmod +x "$HOME/t/foo"

$ PATH="$PATH:~/t"

$ foo
zsh: command not found: foo


$ foo

See also: Why doesn't the tilde (~) expand inside double quotes?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.