Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

For example, when I launch Emacs from the terminal (an interactive shell), I can use "M-x shell".

When I launch Emacs from the dock (which spawns process from some other shell), I cannot, because "grep isn't found" (or 'ls' or 'some other universal UNIX command'). Also, half my non-default applications have stopped working (MATLAB, DrRacket, X11, etc).

  1. How do I change the environment of the shell that is called by the dock?
  2. What shell does the dock call / what else ought I know about different shells on a mac?
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

You should create the file ~/.MacOSX/environment.plist with inside

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PATH</key>
<string>/Users/gio/.dotfiles/bin:/usr/local/bin:/usr/bin/:/usr/sbin/:/bin:/sbin</string>
<key>PYTHONPATH</key>
<string>/Users/gio/.local:/Users/gio/.local/lib/python2.7/site-packages</string>
</dict>
</plist>

What I wrote above is just an example, but I think you get the main point here. After you create the file, log out, log in, and you should be all set. You could have a ruby path as well, etc.

share|improve this answer
    
thanks! what does each component of "<!DOCTYPE ... > do? that is: plist, PUBLIC, "-//Apple//..." and "apple.com/..."; –  Francis Haart Nov 2 '11 at 4:01
    
also, "2. What shell does the dock call / what else ought I know about different shells on a mac?" –  Francis Haart Nov 2 '11 at 4:14
    
The first three lines are meant to identify plist. As for the different shells: every program not called from the terminal, use the environment variables specified above. Every program called from the terminal, use the variables specified in .bashrc/.profile/.zshrc etc. –  Gio Nov 2 '11 at 16:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.