My updated .vimrc now uses the following:
if has("gui_running")
" Gvim
if has("gui_gtk2") || has("gui_gtk3")
" Linux GUI
elseif has("gui_win32")
" Win32/64 GVim
elseif has("gui_macvim")
" MacVim
else
echo "Unknown GUI system!!!!"
endif
else
" Terminal vim
endif
My original answer is below
You could try what I do in my .vimrc:
if has("unix")
let s:uname = system("uname -s")
if s:uname == "Darwin"
" Do Mac stuff here
endif
endif
Although, to be completely transparent, my actual .vimrc reads:
let s:uname = system("echo -n \"$(uname)\"")
if !v:shell_error && s:uname == "Linux"
Mainly for detecting Linux (as opposed to OSX)
I’m not sure if you absolutely have to do that echo -n \"$(uname)\" stuff, but it had to do with the newline at the end of the uname call. Your mileage may vary.