As far as I understand, the usual way to add a path to the PATH
environment variable is by concatenating paths separated by the :
character.
For example, if I want to add three paths to it /my/path/1
, /my/path/2
and /my/path/3
, I would have to do it as follows:
PATH=$PATH:/my/path/1:/my/path/2:/my/path/3
which is not easy to read.
Is there a way to define or add paths to the PATH
variable using a multi-line syntax? Perhaps using arrays? I am looking for something like this:
PATH =
$PATH
/my/path/1
/my/path/2
/my/path/3
In case there are interesting solutions that are shell specific, I am looking for a solution in zsh.
+=
to avoid having to completely rebuild the string. – Chris Down Feb 08 '12 at 17:33