Adding a new entry to the PATH variable in ZSH

后端 未结 6 1976
暗喜
暗喜 2020-11-29 14:43

I\'m using zsh and I\'m trying to add a new entry (/home/david/pear/bin) to the PATH variable but I don\'t know how.

The thing that confuse

6条回答
  •  醉梦人生
    2020-11-29 15:41

    Actually, using ZSH allows you to use special mapping of environment variables. So you can simply do:

    # append
    path+=('/home/david/pear/bin')
    # or prepend
    path=('/home/david/pear/bin' $path)
    # export to sub-processes (make it inherited by child processes)
    export PATH
    

    For me that's a very neat feature which can be propagated to other variables. Example:

    typeset -T LD_LIBRARY_PATH ld_library_path :
    

提交回复
热议问题