I'm writing slim files in Vim and I want them to compile and save as html files when I save. Adding this to my .vimrc makes it happen for files in the current directory:
au BufWritePost *.slim silent !slimrb % > $(echo % | cut -d'.' -f1).html
It doesn't work for files with a path like ../file.slim
since the cut command turns it into
./file.slim
.
I need to use parameter expansions but the % character is reserved for the current filepath when executing an external command in Vim.
How do I compile and save a slim file to a html file regardless of the directory of the file?