You are not logged in.
Following instructions provided by Ubuntu documentation, the pam_env.conf man page as well as the Arch wiki, I am trying to set variables using the suggested format:
TERMINAL=gnome-terminal
PAGER=/usr/bin/less
VISUAL=/usr/bin/vim
EDITOR DEFAULT=${VISUAL}
ZDOTDIR DEFAULT=${HOME}/.config/zsh
PATH DEFAULT=${PATH}:${HOME}/.local/binHowever, ${HOME} and ${PATH} are not being expanded. Presumably because, as per the man page:
Note that many environment variables that you would like to use may not be set by the time the module is called. For example, HOME is used below several times, but many PAM applications don't make it available by the time you need it.
Q. How do I properly set shell agnostic user session variables? I would like to keep things relative and inside the user's domain.
I obviously can't set $ZDOTDIR in .zshrc. I would use ~/.profile if it worked, but from what I've read, it is considered a fallback (left over from sh), it is discouraged by recent posts and is only read by login shells. I have tried:
export TERMINAL="gnome-terminal"
export VISUAL="/usr/bin/vim"
export EDITOR="$VISUAL"
export PAGER="/usr/bin/less"
export ZDOTDIR="$HOME/.config/zsh"
export PATH="$PATH:$HOME/.local/bin"But it has no effect at all in neither zsh nor bash. (I tried this on a blank new user account too)
Any suggestions and enlightenment is greatly appreciated!
Last edited by beanaroo (2015-11-26 05:48:19)
Offline
You only need to set your environment in your login shell. In Zsh, that would be .zshenv and in Bash, .bash_profile or .profile (but the latter will not be read if the former exists). This is explained in the wiki pages for the respective shells.
Not a Sysadmin issue, moving to NC...
Offline
@jasonwryan, it's kind of you to suggest a solution however, as mentioned, I would like to set shell agnostic user session environment variables. This is apparently ~/.pam_environment.
I did mention why ~/.profile is not an option, mainly because it is only read for login shells, partly because it is not always sourced.
Regarding .zshenv. How would I set $ZDOTDIR if the file specifying it is inside $ZDOTDIR?
I am aware I can set it globally and I'm aware I can specify absolute paths but I would like to keep it portable..
Offline
Like I said, you want to set your env with a login shell...
┌─[Shiv ~ ]
└─╼ awk '/ZDOT/' .zshenv
ZDOTDIR="${ZDOTDIR:-$HOME/.zsh}"# edit: as for the pam_environment thing, don't mix the syntax. See http://www.linux-pam.org/Linux-PAM-html … m_env.html
Offline
Sorry if I'm not getting what you mean, but that would require .zshenv to be in $HOME for it to be sourced.
Do you mind elaborating what you mean by 'mixed syntax'? I'm using the same syntax from that page. I see what you meant.
Thanks for your patience.
Last edited by beanaroo (2015-11-26 08:23:52)
Offline
Sorry if I'm not getting what you mean, but that would require .zshenv to be in $HOME for it to be sourced.
That is correct. I'm not aware of any other way of achieving that.
Offline
If I'm understanding things correctly:
The pam_env module is activated before the login command gets to the stage of setting $HOME, $PATH etc. right before starting the shell. So the only way for me to have an entirely seperate $ZDOTDIR would be to specify the absolute path. I can then define the rest in .zshenv. This means total commitment to shell program and environment but nothing a script can't fix when it comes to migration/scaling. It's not pretty, but it appears there is no encompassing method for setting local variables.
Offline
Can't you put that ZDOTDIR in a *.sh file in "/etc/profile.d/"? Those files are executed by the shell so you get to use $HOME in there.
Last edited by Ropid (2015-11-26 11:28:05)
Offline
I definitely could set it globally. But the point of the exercise is to have a solution that is both local and portable.
Offline