Environment Variables for MacVim

354 views
Skip to first unread message

Stephen Rasku

unread,
Jun 11, 2011, 8:57:53 AM6/11/11
to vim...@googlegroups.com
I have some customizations in my .vimrc that depend on environment variables to work.  If I call MacVim from the terminal these customizations work but if I launch it from the dock it doesn't.  I assume this is because my .bashrc is not sourced when launching from the dock but it is when running from the terminal.  Is there a way to ensure that the environment variables are set even when MacVim is launched from the dock?

...Stephen

Ben Schmidt

unread,
Jun 11, 2011, 9:07:47 AM6/11/11
to vim...@googlegroups.com, Stephen Rasku

Hi, Stephen,

Sounds like you have things in your .bashrc (for interactive non-login
shells--or, for some insane reason I have yet to understand,
non-interactive non-login shells when invoked by ssh) that you want in
.profile (for login shells). MacVim, like Terminal, launches a login
shell when it starts Vim instances. But for MacVim it is not an
interactive shell.

Ben.


Billy Huang

unread,
Jun 11, 2011, 9:34:44 AM6/11/11
to vim...@googlegroups.com
are you launching mvim or vi in terminal?

if is mvim, than in the menu, click on 'edit; than select startup settings, see if you that is using the same .vimrc file,

however, what is used in macvim gui should act the same to vi terminal, only some of the color schemes don't work under both.






--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Peter Palmreuther

unread,
Jun 11, 2011, 10:43:05 AM6/11/11
to vim...@googlegroups.com

Put these environment variables in file

${HOME}/.MacOSX/environment.plist

This only works if the variables are static. Within this file no shell evaluations, and therefore no dynamic
settings, are possible.

To edit this file without a proper property file editor use on command line:

plutil -convert xml1 ${HOME}/.MacOSX/environment.plist
vim ${HOME}/.MacOSX/environment.plist
# or mvim ${HOME}/.MacOSX/environment.plist
# save
plutil -convert binary1 ${HOME}/.MacOSX/environment.plist

The syntax of this file is pretty simple:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>VARIABLE_NAME</key>
<string>VARIABLE_VALUE</string>
<key> VARIABLE_NAME </key>
<string> VARIABLE_VALUE </string>
...
</dict>
</plist>

"VARIABLE_NAME" and "VARIABLE_VALUE" of course have to be replaced with the actual variable name,
respectively it's value.

There's no quoting done for values containing space(s), i.e. no double quotes around the value, because in
this XML structure spaces already are preserved.

After a re-login the environment variables set this way should be effective. Me personally would remove them
from any shell rc file (.profile, .bashrc, .zshrc, etc) for avoiding "misbehavior"; Otherwise one might edit just
one place that sets these variables and forget about the other.

A short note at last: these variables are as of then, of course, not set when MacVim (or any other program) is
launched form Dock, but on login and inherited to the started program the normal way (i.e.: the parent makes
the child process launched inherit it's environment settings).

Hope that helps.

Regards,

Peter

Reply all
Reply to author
Forward
0 new messages