5

I've got multi-term mode (derived from ansi-term) with bash started in Emacs 23.3, which is a terminal emulator running in Emacs.

However, I noticed that it did not load my user profile, including environment variables, $PATH, etc.

How do I tell multi-term to start bash with my user profile in ~/.profile?

Thanks.

1 Answer 1

5

Your .profile should be loaded when you log in, not in each terminal. Its purpose is to define environment variables and other settings for the whole session (including your window manager and any program you start from it such as Emacs). It's normal that ~/.profile isn't read when you start a terminal: it's rare to need to define environment variables then. Your shell has an initialization file (.bashrc or .zshrc or similar file), usually used to define functions and aliases and set shell options.

On .profile, its cousins and how they are loaded, read this answer and the ones I link to. All systems have a way to set environments variables when you log in, but there is some variation as to how (a lot of environments read .profile, but some such as yours don't).

5
  • 1
    I see. The problem is when I start bash in Emacs, $PATH doesn't include everything I defined in .profile. But in one of your answers you suggest against adding such definitions in .bashrc, so what should I do? Thanks.
    – hpy
    Sep 14, 2011 at 23:36
  • 2
    You should arrange for your .profile to be read when you log in. How to do that is very dependent on your operating system, login method, desktop environment, etc. Most do it automatically, but since yours doesn't you need to do some set up. So tell us about what your OS/DM/DE/… are. Sep 14, 2011 at 23:45
  • 1
    I am running Emacs 23.3 (which opens a bash window) under Mac OS X 10.6.8, and also the same thing (Emacs w/ bash) under Fedora 15 XFCE. Are the steps for those two very different?
    – hpy
    Sep 15, 2011 at 0:02
  • 2
    @penyuan Yes, they're likely to be different, and you need to give even more information. On the Mac, is this Emacs running on X or on Aqua? On Fedora, in what display manager (if any) do you type your password (text mode, xdm, gdm, kdm, …)? (And I don't know the answer offhand in any case, I suggest asking new questions.) Sep 15, 2011 at 0:11
  • @Gilles do you mind looking here? Ansi-term does not get all the env variables because it does not read .profile
    – Startec
    Apr 13, 2017 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .