From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jim Crossley Newsgroups: gmane.emacs.help Subject: Re: inherit the path environment from .bash_profile (Mac OS 10.5) Date: Fri, 06 Aug 2010 10:00:13 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1281104326 7137 80.91.229.12 (6 Aug 2010 14:18:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Aug 2010 14:18:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 06 16:18:44 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OhNkx-0002pX-EJ for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Aug 2010 16:18:43 +0200 Original-Received: from localhost ([127.0.0.1]:46515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OhNkw-0001dn-K6 for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Aug 2010 10:18:42 -0400 Original-Received: from [140.186.70.92] (port=40819 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OhNiI-0008JA-Fe for help-gnu-emacs@gnu.org; Fri, 06 Aug 2010 10:16:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OhNTG-0005qG-Qs for help-gnu-emacs@gnu.org; Fri, 06 Aug 2010 10:00:28 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:43228) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OhNTG-0005q6-Gp for help-gnu-emacs@gnu.org; Fri, 06 Aug 2010 10:00:26 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OhNTF-00087G-09 for help-gnu-emacs@gnu.org; Fri, 06 Aug 2010 16:00:25 +0200 Original-Received: from 68-191-241-106.dhcp.gwnt.ga.charter.com ([68.191.241.106]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Aug 2010 16:00:24 +0200 Original-Received: from jcrossley by 68-191-241-106.dhcp.gwnt.ga.charter.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Aug 2010 16:00:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 68-191-241-106.dhcp.gwnt.ga.charter.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:blk78QR3NM/s3Mx3/xCHcJeYYDI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74479 Archived-At: Hi Z, Z 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. > >