Path management

Variables

Two variables represent the same list of folders but in different formats. The variable $PATH is a string and the variable $path is an array.

Altering the path array

# Append
path+=my/new/path

# Prepend
path=(my/new/path $path)

Unique

To avoid duplicate entries caused by the append method, use typeset -U to keep only the first occurrence of each duplicated value. Check the Zsh command documentation.

typeset -U PATH path