Reputation: 1635
I'm running Snow Leopard, and trying to run Emacs such that when I start it up, the output of (getenv "PATH")
is the same as the output in Terminal.app
of echo $PATH
.
In other words, I want to start up Emacs from /Applications/Emacs.app
and have it start with my $PATH
. I haven't been able to figure out how to do this within emacs, or with how I start emacs up. So I've spent most of my effort trying to come up with a shell script that I can wrap with something like Platypus or Appify.
So the closest thing I have right now is:
echo MYPASSWD | sudo -S -u USERNAME -i nohup /Applications/Emacs.app/Contents/MacOS/Emacs > /dev/null &
which fails because it seems that nohup throws away my $PATH, despite the -i
flag. The following does not throw away my PATH
but open a superfluous Terminal.app
:
echo MYPASSWD | sudo -S -u USERNAME -i open /Applications/Emacs.app/Contents/MacOS/Emacs > /dev/null &
I've tried running this through do shell script
in an AppleScript, also to no avail.
Am I missing something basic? It doesn't seem like this should be hard. Thanks!
Upvotes: 3
Views: 1123
Reputation: 3019
I ran into the same problem and here's how I worked around it. I created ~/.bashrc and populated it with:
source /etc/profile
source ~/.profile
Upvotes: 1
Reputation: 3539
I wrote a little elisp a while ago to parse the output of env and apply it to the Emacs environment because I didn't want to maintain a plist. The code's at http://paste.lisp.org/display/111574.
Upvotes: 2
Reputation: 1819
GUI applications are not launched by a traditional shell and do not inherit environment variables from the usual places like .profile
, .bash_profile
, etc.
http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html%23//apple_ref/doc/uid/20002093-BCIJIJBH explains that ~/.MacOSX/environment.plist
is the place you probably want to add your favorite equivalent of $PATH.
Upvotes: 2
Reputation: 226
You have to export the PATH to the location of the .app so it would be something like this
export PATH=$PATH:/path/to/the/program
That should allow you to just type EMACS and it will start up.
Upvotes: 0