Skip to content

Commit 165ece4

Browse files
committed
Make :RestartVim work on Mac OS X (issue #36)
Issue 36 on GitHub: #36
1 parent b892cca commit 165ece4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

autoload/xolox/session.vim

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: May 2, 2013
44
" URL: http://peterodding.com/code/vim/session/
55

6-
let g:xolox#session#version = '1.6.2'
6+
let g:xolox#session#version = '1.6.3'
77

88
call xolox#misc#compat#check('session', 2)
99

@@ -452,8 +452,8 @@ function! xolox#session#restart_cmd(bang, args) abort " {{{2
452452
if name == '' | let name = 'restart' | endif
453453
call xolox#session#save_cmd(name, a:bang)
454454
" Generate the Vim command line.
455-
let progname = xolox#misc#escape#shell(fnameescape(v:progname))
456-
let command = progname . ' -c ' . xolox#misc#escape#shell('OpenSession\! ' . fnameescape(name))
455+
let progname = xolox#misc#escape#shell(fnameescape(s:find_executable()))
456+
let command = progname . ' -g -c ' . xolox#misc#escape#shell('OpenSession\! ' . fnameescape(name))
457457
let args = matchstr(a:args, '^\s*|\s*\zs.\+$')
458458
if !empty(args)
459459
let command .= ' -c ' . xolox#misc#escape#shell(args)
@@ -479,6 +479,18 @@ function! xolox#session#restart_cmd(bang, args) abort " {{{2
479479
endif
480480
endfunction
481481

482+
function! s:find_executable()
483+
let progname = v:progname
484+
if has('macunix')
485+
" Special handling for Mac OS X where MacVim is usually not on the $PATH.
486+
let segments = xolox#misc#path#split($VIMRUNTIME)
487+
if segments[-3:] == ['Resources', 'vim', 'runtime']
488+
let progname = xolox#misc#path#join(segments[0:-4] + ['MacOS', 'Vim'])
489+
endif
490+
endif
491+
return progname
492+
endfunction
493+
482494
" Miscellaneous functions. {{{1
483495

484496
function! s:unescape(s) " {{{2

0 commit comments

Comments
 (0)