Allow setting arbitrary environment variables in profile
Note:This bug was repurposed to be more general. It would be nice for a profile to carry environment variables that are set prior to executing the command or shell. The original issue, that $SHELL
is not set for non-login commands, would be covered by this solution.
- iTerm2 version: 3.0.10
- OS version: macOS Sierra
- Attach com.googlecode.iterm2.plist here (drag-drop from finder into this window)
Detailed steps to reproduce the problem:
- Set the initial command for a profile to be different from the login shell, supply --login to the shell if necessary
- Launch that profile
echo $SHELL
What happened:
The system login shell is shown. Other programs (e.g. tmux
) that rely on this variable for default behaviour use the login shell instead of the profile-specified shell. I end up configuring a lot of different places to use /usr/local/bin/bash
, or even worse to try to figure it out dynamically.
What should have happened:
Should be able to transparently use per-profile shells.
I saw that you wrote on another issue that the shell is responsible for setting this variable (not the terminal) so you may not agree. If I read the bash documentation it says that $SHELL
will be set to the login shell if unset at startup. So bash setting it at startup appears to be a fallback behaviour, and it is valid for the calling process to set it.
Besides, it is decidedly inconvenient to not be able to set this automatically:
- I would like to leave my default login shell set to the bare minimum, guaranteed to be present, guaranteed to be compatible with OS X core functionality.
- I would like to have profiles that launch different, more modern shell types (different bash versions, zsh, etc)
- I would like to have
$SHELL
reflect this automatically: a. removing the requirement to try to figure it out and set it myself in the various shell startup scripts b. having subsequent programs liketmux
use it automatically
It seems rather silly to launch zsh
and see $SHELL
set to /bin/bash
. There are quite a few StackExchange questions about these kind of mismatches.