Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Setting zshell path in console [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
ibrunton
n00b
n00b


Joined: 15 Jul 2013
Posts: 18
Location: Canada

PostPosted: Thu Aug 01, 2013 1:52 pm    Post subject: Setting zshell path in console [SOLVED] Reply with quote

How do I set $PATH in zshell in the console?

My understanding is that zsh sources /etc/profile *after* ~/.zshenv, so any $PATH setting in the latter will be overwritten by the former. In other distros, I've fixed this by changing how /etc/profile sets $PATH, but in Gentoo I haven't been able to get it to work.

I want to add $HOME/bin and $HOME/scripts to $PATH and have those available in the console.

Edit:
What has always worked in other distros is to change /etc/profile in this way:
replace "PATH=..."
with "PATH=$PATH:..."

In Gentoo, /etc/profile already does this, but my PATH settings from ~/.zshenv are not recognised in the console.
_________________
github


Last edited by ibrunton on Thu Aug 01, 2013 4:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2826

PostPosted: Thu Aug 01, 2013 3:02 pm    Post subject: Reply with quote

Proper place to do it is in ~/.zshrc

Mine zshrc has:
Code:
if ! [[ "${PATH}" =~ "^${HOME}/bin" ]]; then
   export PATH="${HOME}/bin:${PATH}"
fi

_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3205

PostPosted: Thu Aug 01, 2013 3:47 pm    Post subject: Reply with quote

If your new paths are fixed, that is, they do not change for every user, then in gentoo you are supposed to use the /etc/env.d directory. Create a file called /etc/env.d/99mypath with the following contents
Code:
PATH="/home/<user>/bin"
PATH="/home/<user>/scripts"
Then, run env-update and finally run exec zsh.

As far as I know, zsh in Gentoo does not read /etc/profile. It reads /etc/zsh/zprofile. So, any modifications you want to make directly to the profile file must be made in the /etc/zsh directory.

env-update updates /etc/profile.env which is read by both bash and zsh. That is why if you make a single change to a file in /etc/env.d, it will be reflected in both bash and zsh shells.
_________________
emerge --quiet redefined | E17 vids: I, II
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2826

PostPosted: Thu Aug 01, 2013 4:20 pm    Post subject: Reply with quote

but /etc/profile.d/*.sh is.

Anyway, profile(.d) is executed only on login shells, so it may not exec it if you use gui login managers etc.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
ibrunton
n00b
n00b


Joined: 15 Jul 2013
Posts: 18
Location: Canada

PostPosted: Thu Aug 01, 2013 4:36 pm    Post subject: Reply with quote

SlashBeast wrote:
Anyway, profile(.d) is executed only on login shells, so it may not exec it if you use gui login managers etc.


No login manager, just the console. The path works fine once I start my WM and urxvt, but not in the console.

The file /etc/zsh/zprofile has the same "PATH=...${PATH}" as /etc/profile, yet the $PATH in console doesn't register the directories in $HOME.

ppurka's suggestion (file in /etc/env.d/) seems to have worked.
_________________
github
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2826

PostPosted: Thu Aug 01, 2013 4:47 pm    Post subject: Reply with quote

Well, there was a frackup with zsh some weeks ago, check your /etc/zsh if you dont have zshenv there, if you do, remove it and leave zprofile only there. That's what messing $PATH.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
ibrunton
n00b
n00b


Joined: 15 Jul 2013
Posts: 18
Location: Canada

PostPosted: Thu Aug 01, 2013 6:10 pm    Post subject: Reply with quote

SlashBeast wrote:
Well, there was a frackup with zsh some weeks ago, check your /etc/zsh if you dont have zshenv there, if you do, remove it and leave zprofile only there. That's what messing $PATH.


Nope, only zprofile.

The frackup was probably before I installed Gentoo.
_________________
github
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum