When I do ‘open .profile’ in the terminal I have the following:
export PATH=$PATH:/usr/local/git/bin
Now I installed node.js for Mac and it says,
Make sure that /usr/local/bin is in your $PATH.
How can I add /usr/local/bin to export PATH=$PATH:/usr/local/git/bin?
The
PATHvariable holds a list of directories separated by colons, so if you want to add more than one directory, just put a colon between them:That syntax works in any Bourne-compatible shell (sh, ksh, bash, zsh…). But zsh, which is the default shell in recent versions of MacOS, also exposes the PATH another way – as a variable named (lowercase)
$path, which is an array instead of a single string. So you can do this instead:In either case, you may want to check to make sure the directory isn’t already in the PATH before adding it. Here’s what that looks like using the generic syntax:
And here’s a zsh-specific version:
But in Zsh you can also just mark the array vars as accepting only unique entries:
and even make your own pathlike variables mirrored in arrays: