11

I'm doing this in my .zshrc

   PATH="~/scripts:$PATH"

and if I do echo $PATH it appears as the first thing in the path. Yet this directory isn't included in the executable path (nor for tab-completion). What am I doing wrong? ls ~/scripts shows the directory as expected.

Edit: This works, though... I guess ~ doesn't work in the path?

#PATH="~/scripts:$PATH"
PATH="/Users/yar/scripts:$PATH"

1 Answer 1

16

Use $HOME instead.

PATH="$HOME/scripts:$PATH"
3
  • 3
    Expansion of ~ in PATH is an abhorrent bashism. The PATH-searching library functions execlp or execvp do not expand ~, so other programs that use them to find and run programs in the PATH would also fail to search ~ entries. May 18, 2010 at 21:33
  • 4
    I consider ~ to be a command-line convenience. It shouldn't be used in scripts and variable values for expansion. May 18, 2010 at 23:25
  • @Chris Johnsen, it's amazing, the main impact on my *nix knowledge after switching shells is learning what is universal and what is not. I think zsh is cool, but I've learned quite a bit suffering through the switch (and I'm only two days in). @Dennis Williamson, I'm getting that, and it makes sense, somehow. May 19, 2010 at 0:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .