Search code examples
linuxubuntuzsh

Adding a new entry to the PATH variable in ZSH


I'm using zsh terminal, and I'm trying to add a new entry (/home/david/pear/bin) to the PATH variable. I don't see a reference to the PATH variable in my ~/.zshrc file, but doing echo $PATH returns:

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

So I know that the path variable is being set somewhere. Where is the PATH variable set / modified for the zsh terminal?


Solution

  • Here, add this line to .zshrc:

    export PATH=/home/david/pear/bin:$PATH
    

    EDIT: This does work, but ony's answer above is better, as it takes advantage of the structured interface ZSH provides for variables like $PATH. This approach is standard for bash, but as far as I know, there is no reason to use it when ZSH provides better alternatives.