1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00
Files
til/zsh/add-to-the-path-via-path-array.md
2024-10-07 18:37:23 -05:00

807 B

Add To Path Via Path Array

Typically when managing what is on your path in a Unix shell environment, you override the PATH environment variable with export. This is usually an append or prepend to bring along the existing path entries.

$ export PATH="$PATH:/Users/me/.local/bin"

The zsh shell environment exposes another way of adding to your path. They have a path array which can be a little easier to work with since you can use an array operation instead of string interpolation.

Here is how we'd do the same as above:

$ path+=/Users/me/.local/bin

This works because there is an automatic linking in zsh between arrays and colon-separated strings (scalars). source

source