[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inherit the path environment from .bash_profile (Mac OS 10.5)
From: |
Jim Crossley |
Subject: |
Re: inherit the path environment from .bash_profile (Mac OS 10.5) |
Date: |
Fri, 06 Aug 2010 10:00:13 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) |
Hi Z,
Z <zell08v@orange.fr> writes:
> Is there a way to inherit the path environments of .bash_profile, when
> we lance emacs directly from the dock of Macs?
I looked long and hard for a good way of doing this, so that both GUI
and CLI apps had the same environment (path+vars), no matter how they
were started, e.g. spotlight, dock, bash, etc.
I'm sorry to report there is NO GOOD WAY to do it on a Mac. Here's what
I ultimately ended up adding to my Emacs config:
;; Setup PATH
(setenv "PATH" (shell-command-to-string "source ~/.bashrc; echo -n $PATH"))
;; Update exec-path with the contents of $PATH
(loop for path in (split-string (getenv "PATH") ":") do
(add-to-list 'exec-path path))
The above answers your question specifically about PATH. I'll add this
bit about vars, too, since you'll eventually want it. :)
;; Grab other environment variables
(loop for var in (split-string (shell-command-to-string "source ~/.bashrc;
env")) do
(let* ((pair (split-string var "="))
(key (car pair))
(value (cadr pair)))
(unless (getenv key)
(setenv key value))))
I symlink my ~/.bashrc to ~/.bash_profile, btw.
Good luck,
Jim
>
> In fact, I am using Mac OS X 10.5. I launch carbon emacs from the dock (which
> is the icons list normally at the bottom of the screen) . Then, if I invoke a
> shell from within emacs, it does not inherit the path environment defined at
> .bash_profile !
>
> So in my case, how can I achieve this inheritance of path environments? Maybe
> it suffices to add something at the initialization file .emacs?
>
> Thank you for your ideas.
>
> Z.
>
>