Reputation: 10786
I've written a little .applescript file that can reload Safari. I've tried to hook it's execution into vim's BufWritePost event, (so Safari auto-reloads on file save).
I've placed this in my .vimrc:
function! SaveAndReloadSafari(delay)
" THIS IS WHERE MY PROBLEM IS>>>>>>>>>>>>>>>
!osascript ~/MySrc/applescript/reloadSafari.APPLESCRIPT a:delay
endfunction
if !exists("b:my_autocommands_loaded")
let b:matts_autocommands_loaded = 1
au BufWritePost *.html,*\.css,*.js call SaveAndReloadSafari(0)
au BufWritePost *.scss call SaveAndReloadSafari(2)
endif
As you can see, I want to add a 2 second delay after saving an .scss file (to allow my SCSS files to auto-compile to CSS)
I've confirmed that the only piece of the puzzle missing is my syntax for interpolating the a:delay with the shell command. (Executing the command without a delay
parameter works fine).
What's wrong with my syntax?
Upvotes: 3
Views: 762
Reputation: 392931
You can use :exec
exec '!osascript ~/MySrc/applescript/reloadSafari.APPLESCRIPT ' . a:delay
Upvotes: 6