Skip to content

Commit

Permalink
Make :RestartVim work on Mac OS X (issue #36)
Browse files Browse the repository at this point in the history
Issue 36 on GitHub: #36
  • Loading branch information
xolox committed May 2, 2013
1 parent b892cca commit 165ece4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions autoload/xolox/session.vim
Expand Up @@ -3,7 +3,7 @@
" Last Change: May 2, 2013
" URL: http://peterodding.com/code/vim/session/

let g:xolox#session#version = '1.6.2'
let g:xolox#session#version = '1.6.3'

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

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

function! s:find_executable()
let progname = v:progname
if has('macunix')
" Special handling for Mac OS X where MacVim is usually not on the $PATH.
let segments = xolox#misc#path#split($VIMRUNTIME)
if segments[-3:] == ['Resources', 'vim', 'runtime']
let progname = xolox#misc#path#join(segments[0:-4] + ['MacOS', 'Vim'])
endif
endif
return progname
endfunction

" Miscellaneous functions. {{{1

function! s:unescape(s) " {{{2
Expand Down

0 comments on commit 165ece4

Please sign in to comment.