Interpolate Vim function and shell command arguments
I wrote a small .applescript file that can restart Safari. I tried to hook it up to the vim BufWritePost event (so that Safari automatically reloads when the file is saved).
I posted 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 the .scss file (so that my SCSS files will automatically compile to CSS)
I have confirmed that the only drawback of the puzzle is my syntax for interpolating a: delay with a shell command. (Running the command without a parameter delay
works fine).
What's wrong with my syntax?
+3
source to share