What I have observed:
When I type emacs
in gnome-terminal, it launches in the same environment, with variables set in .bashrc
. If I use a keyboard shortcut to the command emacs
, it opens in an environment that does not have these variables.
Questions:
- Is there a reason for this behaviour?
- How can I get emacs to open in an environment with settings from
.bashrc
? - If I have root access, can I set these variables 'system-wide'?
Additional background: I need is to be able to access the variables from within R, as described in a related SO question (How to access a bash environment variable from within R in emacs), and I also need the path to my texlive distribution for Auctex. The present question is different in that I am more generally interested in the difference between launching emacs from within the terminal and launching emacs from the Applications menu, Gnome-do, or keyboard shortcut that call either emacs
or /usr/bin/emacs23 %F
.
~/.bashrc
is usually read for secondary interactive shells after you log in. If you want to initialise your parameters on login the use~/.profile
instead. To apply you parameters system-wide use/etc/profile
. It's the first file read by bash.To make things clearer I think I'd explain a bit more.
/etc/profile
, then~/.profile
and parameters/variables mentioned there are initialised. However you don't see this shell as terminal because the X-window system GUI is running.gnome-terminal
~/.bashrc
is read and and the parameters/variables declared in it are available to the secondary terminal only. Note that this secondary terminal is a child process of your login shell..bashrc
was not available for the main login shell; so it's not available for applications too. So anything in.bashrc
won't be available for those applications if run from menu. But when you open agnome-terminal
and executes command from there, applications are launched as children ofgnome-terminal
and inherits.bashrc
's parameters from it.