5

I'm using Ubuntu 14.04. I used chsh to set my default shell to /usr/bin/zsh.

My ~/.zprofile defines several environment variables, e.g. export EDITOR=vim. Yet after logging in and starting GNOME Terminal, these variables are not set. After running zsh -l, they are:

% echo $EDITOR

% zsh -l
% echo $EDITOR
vim
%

So apparently when zsh is run on login it does not know it's a login shell and therefore does not read .zprofile? What gives?

As far as I can tell, this was working until recently, then suddenly it wasn't, so perhaps an upgrade broke something?

ke.
  • 177

1 Answers1

7

So apparently when zsh is run on login ...

You're running zsh in GNOME Terminal, not on login. Compare by switching to a TTY (CtrlAltF1), and logging in.

it does not know it's a login shell

The term "login shell" is overloaded:

  1. It's the shell mentioned in your passwd entry. Console-based login methods usually start this shell (try the TTYs, or sudo -l, or su -). "Login shell" with this context is used in discussion of user accounts.
  2. A shell can be run as a login shell, irrespective of whether it is a login shell(1) of the user. With most Bourne-like shells, that's obtained by either using -l when run manually, or by using - as the first character of argument 0 when launched indirectly (by login, sudo, su, etc.). This meaning is used while discussing invocation of shells.

So, it isn't a login shell(2), because we are discussing how it is started (invocation).


.zprofile is read by login shells (2). GNOME Terminal does not run a login shell (2) by default. You have to tell it do so:

  1. Go to Edit -> Profile Preferences.

  2. Select the Title and Command tab.

  3. Notice how the Run command as login shell checkbox is unchecked! Check it.

muru
  • 207,228