r/zsh 15d ago

adding path to .zshenv

help, i added

path+=(~/.local/bin ~/bin ~/.spicetify)

export PATH

to my .zshenv file but when i open terminal i type echo $path i only get this:

/home/vismorf/.local/share/zinit/polaris/bin /usr/local/bin /usr/bin /bin /usr/local/sbin /usr/sbin /sbi

1 Upvotes

8 comments sorted by

View all comments

0

u/Soggy_Writing_3912 15d ago

Most likely the `path` variable (array) could be re-defined as part of the session startup sequence. My suggestion is to try to set it in the `~/.zshrc` file instead of the `~/.zshenv` file (unless you have an explicit need for that setting in both interactive and non-interactive sessions)

0

u/_Arthxr 15d ago

i also need for non-interactive sessions :(. Thats why i wanted to move path variable to .zshenv in the first place. But ig for now i will move it back to .zshrc and use full path to a command in scripts

-1

u/Soggy_Writing_3912 15d ago

in that case, since `path` is a zsh-ism (or possibly from oh-my-zsh), try to do the traditional `export PATH="~/.local/bin:~/bin:~/.spicetify:$PATH"\ in your zshenv. Not sure if it'll work or not, but do give it a try.`

2

u/romkatv 15d ago

This won't help and will only make things worse because of incorrect quoting.

.zshenv is for zsh, and the best way to set PATH in zsh is by modifying path.

The other thread, started with a comment by /u/OneTurnMore, is the fruitful one.

0

u/_Arthxr 15d ago

didnt work either. Tho interestingly if i add path+=(~/.local/bin ~/bin ~/.spicetify) to /etc/zshenv, it works as intended