Pitfalls

  1. Incorrect use of the tilde expansion.

    • export PATH=~/.dir:$PATH expands to /home/username/.dir
    • export PATH="~/.dir" expands to ~/.dir
    • export PATH="$HOME/.dir" expands to /home/username/.dir
    • export PATH=$HOME/.dir expands to /home/username/.dir

  2. Specifying the incorrect directory.

    • N.B. The exact parent directory of the desired executable must be specified – not the grandparent, great-grandparent, etc.
    • For example, if you want to run the program foo.sh which lives in /usr/bin/run/foo.sh, add the /usr/bin/run directory to your path; having /usr/bin in your path is not sufficient.

Tips

  1. According to the user guide, set your path in .zshenv.

  2. Add typeset -U path to your .zshenv to not add duplicate entries to your path.

  3. Modify your path like path=(~/bin ~/progs/bin $path).

    • PATH and path both set the search path for commands. These two variables are equivalent, except that one is a string and one is an array. If the user modifies PATH, the shell changes path as well, and vice versa. 1

Additional Sources: